469,946 Members | 2,019 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

Form.Show() acting weird

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!
Nov 15 '05 #1
2 7193
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
"Zzzbla" <b@man.com> wrote in message
news:MP************************@news.microsoft.com ...
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!

Nov 15 '05 #2
hi!

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

Where can I learn more about invoke?

Thanks in advance!

In article <#p**************@TK2MSFTNGP12.phx.gbl>,

je**********@yahoo.com says...
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

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

37 posts views Thread by Geoff Jones | last post: by
7 posts views Thread by Michael Erlewine | last post: by
16 posts views Thread by iwdu15 | last post: by
reply views Thread by Miro | last post: by
9 posts views Thread by Anil Gupte | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.