Resolved A usercontrol on a form with long running method on BackgroundWorker

aaaron

Well-known member
Joined
Jan 23, 2011
Messages
216
Programming Experience
10+
I have a usercontrol on a form that contains a long running method.

I need the usercontrol to show on the form for the user to click something on it.

I also need to run a method that is on the usecontrol from a BackgroundWorker that is created by the form.

I think I'm up a creek without a paddle but 've seen magic o this site before so I thought I'd ask.

Is there any way??

Edited after the two replies.

Is this different than what I said before appeared to say?
 
Last edited:
Sheepings ,

I meant I have some code that could be improved by using a thread like you show. I've already run your code. I had to put a counter in the loop to stop it after a while.
 
Last edited:
You don't need this :
VB.NET:
While True
Debug.Write(s) 'This always runs and is running on non-ui thread
End While
Remove it, as it was there for example purposes.
 
VB.NET:
 While True
     If mAbort Then Exit While
End While

I added a button (button event not shown) to end the loop.

BTW, When I said (way above) I was testing it was probably not the best word to use. I didn't mean I want to be sure the app was OK. I was, in each instance, checking to see if some small amount of code worked the way I thought it would. The entire thing has no other useful purpose. Just playing.

Thanks again for the help.
 
Last edited:
The following example program creates a form that calculates Fibonacci numbers. The calculation runs on a thread that is separate from the user interface thread, so the user interface continues to run without delays as the calculation proceeds.

There is extensive support for this task in Visual Studio.
 
The following example program creates a form that calculates Fibonacci numbers. The calculation runs on a thread that is separate from the user interface thread, so the user interface continues to run without delays as the calculation proceeds.

There is extensive support for this task in Visual Studio.
There is no example.
 
Back
Top