How to create a separate thread to do some operation periodically and update UI in WPF?I'm stack
Posted
by black sensei
on Stack Overflow
See other posts from Stack Overflow
or by black sensei
Published on 2010-05-18T15:49:14Z
Indexed on
2010/05/18
15:50 UTC
Read the original article
Hit count: 199
Hello Experts!
I'm trying to do a periodic separated thread operation let's say check for internet connection or check for user's info via web service and update the user interface.
i've tried with quartz.net to implement that.So i created an inner class for the window i need to update.That inner class does what is meant for but the problem is that i don't know how to access parent's(window class) members form the child(inner class). for example
public partial class Window2 : Window
{
private int i;
public Window2()
{ InitializeComponent();
}
public string doMyOperation()
{
//code here
return result;
}
public class Myclass :IJob
{
public void Execute(JobExecutionContext context)
{
string result = doMyOperation();
//Now here i could be able to call a label of name lblNotif
//lblNotif.Content = result;
}
}
}
Well the whole idea works but i'm stacked at here i need to access a controls of Window2
Since i'm stacked i tried Spring.Net way of implementing Quartz hoping that i could use MethodInvokingJobDetailFactoryObject
and rather have the Operation done on Window2 itself.But for some reason i'm having an exception
Cannot resolve type [System.Windows.Window2,System.Windows];, could not load type from string value System.Windows.Window2,System.Windows
and the wiring is done so
<object name="UpdateLabelJob" type="System.Windows.Window2,System.Windows"/>
What i'm i doing wrong here?Is that a way round? thanks for reading and for helping out
© Stack Overflow or respective owner