Tuesday, March 18, 2008 3:31 PM
I have a wpf window that has a canvas and an image placed on the canvas.
In the code for this window I am using events mouse down, mouse up, and mouse move.
However, I also need to kick of a thread that every 1 seconds reports back to the ui thread with the current mouse position = I need to test when the mouse hasn't moved for a short period of time.
However, unlike in windows forms when I'd use the invoke.required on a text box or something with a delegate in order to post info back from the thread, in this case I know that wpf uses the dispatcher.invoke or .begininvoke, however I'm not UPDATING a UI Element - I'm trying to set booleans and pass in a mouse positions (as a point) back to the UI thread.
So can anyone please explain (simply) how to do this?
I've used the windows forms method for threads to update boxes and labels on the UI, but that 'approach' doesn't seem to be what I need to do in this case.
Please - I need this figuring out today as I have a deadline to meet for my 3rd year project.
Tuesday, March 18, 2008 4:39 PM
- Proposed As Answer by narfzort Tuesday, September 02, 2008 6:45 PM
Tuesday, March 18, 2008 5:08 PM
Take a look at
Tuesday, March 18, 2008 6:56 PM
Hi. As my post mentioned I'd already had a look at the Dispatcher.Invoke but couldn't work out how to use it in my example as no UI element had to be 'updated'.
However you are wonderful in knowing and suggesting the (heretofore unknown to me) DispatcherTimer - which is EXACTLY what I want to use!!!!
Awesome! Huge thanks to you.
However I need to use this in a time interval of around 1/10th down to 1/100th of a second, but the msdn example only gives lowest 1sec.
Thanks so much...
Tuesday, March 18, 2008 9:02 PM
DispatcherTimer.Interval is of type TimeSpan
TimeSpan has several convenience methods to create subsecond time spans.