Call the ReportProgress method from the worker, and handle the ProgressChanged to update the current state.
Check if invoke is required, then call BeginInvoke. Private void AdjustControls() { if (this. InvokeRequired) { this.
Invoke(new MethodInvoker(this. AdjustControls)); } else { label1. Text = "Whatever"; } }.
I tried this. But it doesn't work. Can yu give me more details.
Thanks in advance! – uhu Jul 19 '10 at 14:47 Sorry my bad, I fixed it up a bit. If AdjustControls takes parameters, for example, if it is an event handler, then you cannot use MethodInvoker, you have to define a delegate for it.
– Kurt Jul 19 '10 at 15:27.
I feel a little weird tooting my own horn here, but you may find some use from the ThreadSafeControls library I wrote for exactly this purpose.
You cannot change controls directly inside a thread which did not create them. You can use an invoke method as shown above, or you can use the BackgroundWorker ProgressChanged event. Code used inside BackgroundWorker DoWork: myBackgroundWorker.
ReportProgress(50); // Report that the background worker has got to 50% of completing its operations. Code used inside BackgroundWorker ProgressChanged: progressBar1. Value = e.
ProgressPercentage; // Change a progressbar on the WinForm.
How to access a control from another thread which didn't create this control. I faced this issue more than 1 time, I decided to collect info about it and made some changes on the code to simplify this problem to you cause it's really annoying and confusing to work with threading stuff. Here is a small code solves this problem FOREVER and in ANY case.
Cross thread operation not valid: Control "XXXXXXXXXX" accessed from a thread other than the thread it was created. Private Strt As System.Threading. Strt = New System.Threading.
From the previous code you will notice 2 things:1st: AccessControl the sub which will be delegated.2nd: ' Working code - which doesn't need a delegate to get it work. In other mean, it doesn't show up the error message you receive. From the previous code you will notice that all the codes which wasn't working in the threading sub will be added after "Else" line.
Examples for some codes which needs to be delegated:(Control).VisibleMe.OpacityMe. ShowInTaskbar I hope I simplified it enough, and now no worry about this issue again.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.