Threading

F

Fredje

Hello,

I have the following problem:
I'm making a application that add at runtime usercontrols.
Each usercontrol have a function that converts a image.
This conversion takes a while and at the time the function is running the
applications blocks.
So I want to implement Threading but only for the moment this function is
running.
I have to pass arguments to the function like width, height,...

How can I prevent that the application doesn't block when this function is
running?

Thanks in advance.
 
D

Drebin

You answered your own question: by starting a thread..

You can't send ThreadStart any arguments, so what most people do - is create
a class, that will do the thread work.. so in psuedo-code:

-create an instance of the threadworker class (call it objWorker)
-assign height, width, other properties to objWorker
-create a thread, and assign it to objWorker.DoWork()

hth
 
A

AlexS

You can pass back created picture or controls to UI thread. Just remember,
that you can't update UI thread controls (main form) reliably from another
thread. Take a look at InvokeRequired and Invoke/BeginInvoke methods of
Control object.

HTH
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top