Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Help threads!!

 

Please help!!

 

I want to spawn multiple threads which will call a third party bitmap transition method. Basically enabling an image in a picture box to switch from one to another with a choice of transitions in between. Easy enough for a thread to do this sequencially.

 

ie

PictureBox1 5 second transition begins

1 sec .. 5 secs

PictureBox1 5 second transition ends

then

PictureBox2 5 second transition begins

1 sec .. 5 secs

PictureBox2 5 second transition ends

 

The problem is that I would like to be able to perform 2 or more transitions at once. After querying support for the product, the advice to "research threading" was given.. thanks alot!!

 

My question is how can concurrent threading be implemented when the thread itself is a method that takes a length of time. How can a thread containing an external method be told to stop executing before it has completed it's task, while another thread calling the same method catches up with it? Then resume the first thread where it was stopped.

 

ie

PictureBox1 5 second transition begins

1 sec..

then

PictureBox2 5 second transition begins

1 sec..

PictureBox1 5 second transition continues

2 sec..

then

PictureBox2 5 second transition continues

2 sec..

..

..

PictureBox1 5 second transition ends

PictureBox2 5 second transition ends

 

Been pulling my hair out reading up on Threads and Threadpools. Syncronisation sounded like what I needed, but after researching it seems that prevents multiple threads accessing data at the same time.

 

 

If this makes no sence I'll expand where it's unclear. Any advise, suggestions, references or samples would be much apprecitated!!

 

Thanks

Edited by SEVI
  • *Experts*
Posted

I doubt what you're talking about it directly possible...

 

You can easily start two more threads and have both of the actions happening at once, but having an action stop in the middle of execution will not be possible I think. You can use Thread.Suspend() to suspend execution of your thread, but only once it gets to a safe-point. That means it won't stop in the middle of doing something, it will stop once it gets finished and not continue untill to start it again.

 

You might look into using the SyncLock keyword in VB, however, as it prevents two threads running the same thread procedure from executing the same bit of code at the same time.

  • 1 year later...
Posted
You can suspend a thread that is not in its critical section. Suspending a thread that is its critical section would cause either dead lock or starvation, depending on the circumstances.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...