This is a migrated thread and some comments may be shown as answers.

RadProgressBar and waiting status

3 Answers 553 Views
ProgressBar
This is a migrated thread and some comments may be shown as answers.
Mirko
Top achievements
Rank 1
Mirko asked on 28 Aug 2009, 02:43 PM
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

3 Answers, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 28 Aug 2009, 09:30 PM
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
0
Mirko
Top achievements
Rank 1
answered on 09 Sep 2009, 04:01 PM
Hi Robert,
    Thanks for your help but in my case it doesn't work.
My code are :

 

delegate void setProgessBarCallback();  
private System.Timers.Timer m_timer;  
setProgessBarCallback _setProgessBarCallback ;  
 
MyUC()  
{  
InitializeComponent();  
m_timer = new System.Timers.Timer();  
m_timer.AutoReset = true;  
m_timer.Interval = 1000;  
m_timer.Elapsed += new System.Timers.ElapsedEventHandler(m_timer_Elapsed);  
_setProgessBarCallback = new setProgessBarCallback(setProgessBar);  
 
}  
 
void MyFunction()  
{  
StartProgressBar();  
 
//Do something
 
StopProgressBar();  
}  
 
void StartProgressBar()  
{  
    m_timer.Start();  
}  
 
void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)  
{  
    this.Invoke(_setProgessBarCallback);  
}  
 
private void setProgessBar()  
{  
    this.radProgressBarElement1.PerformStepValue1();  
    if (this.radProgressBarElement1.Value1 >= this.radProgressBarElement1.Maximum)  
        this.radProgressBarElement1.Value1 = this.radProgressBarElement1.Minimum;  
    this.radProgressBarElement1.Text = this.radProgressBarElement1.Value1.ToString();  
    //this.radStatusStrip1.Refresh();  
    //this.radStatusStrip1.RepaintElements(radProgressBarElement1);  
    //Application.DoEvents();  
}  
 


Any suggestions?

Mirko
0
Victor
Telerik team
answered on 15 Sep 2009, 09:52 AM
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.
Tags
ProgressBar
Asked by
Mirko
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Mirko
Top achievements
Rank 1
Victor
Telerik team
Share this question
or