Multi Threading

  • Thread starter Thread starter Glyn Meek
  • Start date Start date
G

Glyn Meek

1) I have an 'animated' graphic window that displays as the application is
loading and doing its initialization. This animation routine is staretd as
a separate thread at the beginning of the Mainform load.
2) The animation form is smaller than the screen and so overlays the main
application window.
3) Rather than have the animation thread terminate when the main application
has finished loading/initializing, I want to have it terminate when a user
selects a menu item from the main application and goe off to do the
appropriate application programming.
4) Everything appears to work well, in that the animation 'animates' (!),
the main application loads and initializes, and the main application form
displays under the animation window and all the menu items appear...
....but
5) None of the main application form menu items appear to be 'live'.

My intention is that the first action taken when one selectes a main
application menu item is to 'kill' the animation thread, but I cannot get to
that point if I cannot recognize a menu click event on the main application
form..

Now, I realize that multithreading has a number of 'gotchas', but I cannot
figure out what I am a) not doing or b) am trying to do but am not allowed
to do.

Anyone help?

Regards

Glyn Meek
 
Don't see anything obviously wrong, but perhaps a better approach would be
to do animation on a timer event (Forms.Timer as opposite to
System.Threading.Timer). This is by the way what OpenNETCF Animation control
is doing (hint, hint)

I assume whatever you do right now to animate your graphics is done with
Control.Invoke in mind
 
I see what you mean. Of course using forms timer will not work if your form
is busy initializing. And even Invoke from a thread will not either, since
Invoke simply posts a message to the UI thread.

I think that the problem witn menus might have something to do with the lack
of UI idle time. One thing that comes to mind is to drop the animation
thread priority at the end of the main form's load event (after the
initialization is done)
 
Alex...thanks. After reading your recommendations, I 'simplified' and
reduced my expectations! Rather than having it animate in real time while
the initializations were taking place, I started a timer loop after the
short initializations and as I really needed it to sit there until a user
makes their first selection, it works perfectly now and was MUCH simpler
than using multithreading.

Glyn
 
Back
Top