Hi all,
I am trying to write a software where I want to put some UI in the form that would indicate the loading process(progress bar, loading image etc).
Please advice how to do it since when a form runs some code all the form gets static. Threading is also not helping either
Umair.P 0 Newbie Poster
Recommended Answers
Jump to PostLizR you sure you are meaning pinvoke?
i do it by invokerequired
this example here, is setting a button enabled
private delegate void UpdateBtnContinueDelegate(); private void UpdateBtnContinue() { if (this.InvokeRequired) { UpdateBtnContinueDelegate updateCount = new UpdateBtnContinueDelegate(this.UpdateBtnContinue); this.Invoke(updateCount); } else { this.btnContinue.Text = "Continue"; this.btnContinue.Enabled = …
Jump to Postthe concept is right, i gave you an example with a button, you can do the same with a progress bar
this assumes you have progressbar name pbStatusprivate delegate void UpdatePbDelegate(); private void UpdatePb() { if (this.pbStatus.InvokeRequired) { UpdatePbDelegate updateCount = new UpdatePbDelegate(this.UpdatePb); this.pbStatus.Invoke(updateCount); …
Jump to Postsorry forgot the thread part
private void DownloadData() { //your code in here that downloads your values } private void GetDropDownValues() { Thread t= new Thread(new ThreadStart(DownloadData)); t.Start(); while (t.IsAlive) { UpdatePb(); System.Threading.Thread.Sleep(50); } }
also, i wouldn't recommend it, but you can call UpdatePb() from anywhere …
All 9 Replies
LizR 171 Posting Virtuoso
Umair.P 0 Newbie Poster
dickersonka 104 Veteran Poster
Umair.P 0 Newbie Poster
dickersonka 104 Veteran Poster
dickersonka 104 Veteran Poster
LizR 171 Posting Virtuoso
dickersonka 104 Veteran Poster
Jugortha -1 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.