Form.Show() acting weird

Z

Zzzbla

Hello,

I'm writing a reminders project and I've been having some difficulties.

It starts with a simple class that contains a timer and NotifyIcon, where
the main function initializes the timer followed by Application.Run();

Whenever the timer figures out it has to do something (pop a reminder) -
it creates an instance of the reminder window and calls the Show() method
of that form.

Now - what happens is that the form appears in the taskbar, but when you
click it, it stops responding. When I use ShowDialog instead, it runs OK.

Why can't I just show the form? Should I run it in a new thread?

Thanks in advance!
 
J

jennyq

Hi, Zzzbla:
According to the behavior, it seems to me the form doesn't participate
in the messageloop of application(since it is created in timer's thread).
It's better to do all the form related thing in the main thread. e.g. You
can implement creating and showing the form in one of form's eventhandlers,
then you trigger this event in Timer thread by calling through invoke, which
will notify the the main thread to do creating and showing.

Hope it helps!

Qiu
 
Z

Zzzbla

hi!

It sounds weird but reasonable, that this is the problem... :)

Where can I learn more about invoke?

Thanks in advance!

(e-mail address removed) says...
 

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