My form creates a backgroundworker that every 6 secs checks something. Result is 1-100 and I want to display this.
But if i do it straight forward i get som cross-thread errors so I after some research delegates is the way to do it.
ive created inside the Form1 class:
public delegate void SetProgressbarValueDelegate(int val);
but how do i "connect it" to actually update the progressbar?开发者_运维技巧
Thanks
Assuming your are using WinForms, The BackgroundWorker
class raises a ProgressChanged event which will automatically be marshalled back onto your UI thread. You should make updates to your User Interface within your handler for this event.
There are some simple examples of how to use BackgroundWorker
within the MSDN documentation.
精彩评论