My code is as,
Ping ping = new Ping();
ping.PingCompleted += ping_PingCompleted;
ping.SendAsync(strTerminalName, 60, Encoding.ASCII.GetBytes("sfk"));
private void ping_PingCompleted(object sender, PingCompletedEventArgs e)
{
Terminal.ChangeTerminalStatus(this.imgCurrent, TerminalStatus.UserOFF);
}
Terminal has static method ChangeTerminalStatus which i am calling in that ping_PingCompleted.
ERROR i got :-
The calling thread cannot access this object because a different thread owns it WPF.
Since i tried to change UI Property of a window in that statis method.
I searched and got solution to use Dispatcher.BeginInvoke method.
When i tried to use this in a class which i has ping , Dispatcher.BeginInvoke it throws error says
Error 2 An object reference is required for the non-static field, method, or property 'System.Windows.Threading.Dispatcher.BeginInvoke(System.Delegate, params object[])' D:\Net Projects\mercurial\icafemanager\ICMBusiness\Terminal.cs 124 17 ICM
Help me out in this.