How to access parents' members from a inner class in WPF?
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
17:20 UTC
Read the original article
Hit count: 169
Hello Experts!
I'm trying to do scheduled operation let's say to check for user's credit left via web service call and update the user interface.
i've tried with quartz.net to implement the scheduling bit.i created an inner class in the window class i need to update.That inner class has the method that calls the webservice and the result needs to be displayed back to the UI. here is an example of what i did.
public partial class Window2 : Window
{
private int i;
public Window2()
{
InitializeComponent();
}
public class Myclass :IJob
{
public void Execute(JobExecutionContext context)
{
string result = doMyOperation();
//i'll like to call parent label member of name lblNotif
//is something like parent.lblNotif.Content = result;
//possible?
}
public string doMyOperation()
{
//calling the wermethod to retreive user's balance
return result = service.GetUsersBalace(user);
}
}
}
Well the quartz bit is working and this post is not about quartz. here are my questions
Question 1 : How is it possible to access Window2 controls, for instace lable lblNotif?
Question 2 : If my thinking about this is wrong, what is done as best practice to solve my kind of problem, where an application need to do an operation let's say every 5mn and update the the UI.
Question 3 : i at first tried to use the backgroundworker and i felt like i can't do the scheduling bit with it.Is that correct or i'm wrong.
thanks for those who commented already and sorry for those who didn't get the meaning of my post.I hope this will be a bit clearer.Thanks for reading
© Stack Overflow or respective owner