Michael,
It appears that you are using the timer in the System.Timers namespace
or the System.Threadin g.Timer class, and not the timer in the
System.Windows. Forms.Timer component. This is fine, but this means that the
thread that the event fires on is not guaranteed to be on the UI thread.
What you have to do is create a method which will call ShowDialog, and
then a delegate with a signature that matches the signature of the method
which will perform this call. Then, pass an instance of that delegate to
the Invoke method on a control on the form (or the form itself) and the call
to ShowDialog will be performed on the UI thread.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard. caspershouse.co m
"Michael Howes" <mh****@xforteb io.comwrote in message
news:eZ******** ******@TK2MSFTN GP06.phx.gbl...
>
I and trying to detect idle time or sorts in the applications I'm
building.
To do this the main Form also inherits from IMessageFilter and I listen
for WM_MOUSEMOVE. When that happens I reset a DateTime.
To check the time between last mouse move I have a timer
(System.Threadi ng.Timer)
If the the DateTime math meets a certain threshold I want to show our
login dialog, essentially locking people out of this unattended app.
When I try and ShowDialog() on my login form I get a threading error
because of the owner I try and pass in.
this failed so I tried packing up the main form in the thread so it was
passed as an argument (object state) of the timer and use that instead of
this in the timer callback but that didn't work either.
what's the proper way to show the login dialog when shown because of a
timer?
thanks
mike