RadProgressBar and waiting status

4 posts, 0 answers
  1. Mirko
    Mirko avatar
    8 posts
    Member since:
    May 2007

    Posted 28 Aug 2009 Link to this post

    Hello,

        I'm developing an application for my company. I use a radprogressbar and a radstatusstrip into an user control, that is inside a radribbonform. I use those control as waiting status in some operation.
    I tried backgroundworker and timer but the progressbar after the operation finish. Also i use statusstrip.Refresh() but it doesn't work.

    Please help me. !!!!

    Mirko
  2. Robert
    Robert avatar
    82 posts
    Member since:
    Jun 2009

    Posted 28 Aug 2009 Link to this post

    Hello Mirko,

    Here is a simple implementation of using a separate thread to update a progress bar and status bar on a user control.

    Main Form:
        public delegate void DelegateTickProgress(); 
     
        public partial class Form1 : Form 
        { 
            public DelegateTickProgress _delegateTickProgress; 
            Thread _workerThread; 
            
            public Form1() 
            { 
                InitializeComponent(); 
                _delegateTickProgress = new DelegateTickProgress(this.TickProgress); 
            } 
     
            private void radButton1_Click(object sender, EventArgs e) 
            { 
                statusUserControl1.ResetStatus(); 
                _workerThread = new Thread(new ThreadStart(this.WorkerThreadFunction)); 
                _workerThread.Start(); 
            } 
     
            private void WorkerThreadFunction() 
            { 
                for (int i = 0; i < 10; i++) 
                { 
                    Thread.Sleep(100); 
                    this.Invoke(this._delegateTickProgress); 
                } 
            } 
     
            private void TickProgress() 
            { 
                statusUserControl1.UpdateStatus(); 
            } 
        } 

    User Control:
        public partial class StatusUserControl : UserControl 
        { 
            public StatusUserControl() 
            { 
                InitializeComponent();        
            } 
     
            public void ResetStatus() 
            { 
                radProgressBar1.Value1 = 0; 
            } 
     
            public void UpdateStatus() 
            { 
                radProgressBar1.ProgressBarElement.PerformStepValue1(); 
                radLabelElement1.Text = radProgressBar1.Value1.ToString(); 
            } 
        } 

    The WorkerThread function is where you should perform any time consuming operations.

    I hope this helps.

    - Robert
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mirko
    Mirko avatar
    8 posts
    Member since:
    May 2007

    Posted 09 Sep 2009 Link to this post

    Hi Robert,
        Thanks for your help but in my case it doesn't work.
    My code are :

     

    1 delegate void setProgessBarCallback();  
    2 private System.Timers.Timer m_timer;  
    3 setProgessBarCallback _setProgessBarCallback ;  
    4  
    5 MyUC()  
    6 {  
    7 InitializeComponent();  
    8 m_timer = new System.Timers.Timer();  
    9 m_timer.AutoReset = true;  
    10 m_timer.Interval = 1000;  
    11 m_timer.Elapsed += new System.Timers.ElapsedEventHandler(m_timer_Elapsed);  
    12 _setProgessBarCallback = new setProgessBarCallback(setProgessBar);  
    13  
    14 }  
    15  
    16 void MyFunction()  
    17 {  
    18 StartProgressBar();  
    19  
    20 //Do something
    21  
    22 StopProgressBar();  
    23 }  
    24  
    25 void StartProgressBar()  
    26 {  
    27     m_timer.Start();  
    28 }  
    29  
    30 void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)  
    31 {  
    32     this.Invoke(_setProgessBarCallback);  
    33 }  
    34  
    35 private void setProgessBar()  
    36 {  
    37     this.radProgressBarElement1.PerformStepValue1();  
    38     if (this.radProgressBarElement1.Value1 >= this.radProgressBarElement1.Maximum)  
    39         this.radProgressBarElement1.Value1 = this.radProgressBarElement1.Minimum;  
    40     this.radProgressBarElement1.Text = this.radProgressBarElement1.Value1.ToString();  
    41     //this.radStatusStrip1.Refresh();  
    42     //this.radStatusStrip1.RepaintElements(radProgressBarElement1);  
    43     //Application.DoEvents();  
    44 }  
    45  


    Any suggestions?

    Mirko
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 15 Sep 2009 Link to this post

    Hi Mirko,

    Thank you for writing. I copied the code that you provided and everything works as expected. Please send a sample application which demonstrates the issue so that I may assist you further. I am looking forward to your reply.

    Best wishes,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top