"The calling thread cannot access this object because a different thread
owns it" how i can resolve it
i m not understanding the logic of dispatcher in my code and my code is
when i click the button after 5 sec a message box should accour but its
giving me exception mentioed above
//this code is of my button click
private void button1_Click(object sender, RoutedEventArgs e)
{
dt[0] = DateTime.Now;
Thread th = new Thread(time);
//textBox2.Dispatcher.Invoke(( new Action=>textBox2.Text=.ToString));
th.Start();
//Thread thr = new Thread(time);
//thr.Start();
}
//this function is
private void time()
{
TimeSpan time_diference=new TimeSpan();
time_diference=DateTime.Now - dt[0];
while (true)
{
MessageBox.Show(time_diference.TotalSeconds.ToString() + "
textbox2 " + textBox1.Text.ToString());
if (time_diference.TotalSeconds.ToString() == textBox2.Text)
{
FBC.Post("/me/feed", new { message = textBox1.Text });
MessageBox.Show("posted");
break;
}
}
}
No comments:
Post a Comment