I am trying to display error message notification using MessageBox.Show() method. But I am getting Cross thread operation issue. I used the below code. How can I resolve the cross thread issue? I tried with MethodInvoker but it is not solving my issue. Kindly suggest me the guidelines to resolve this issue.
public static class Notification()
{
public static void ShowErrorMessage(IWin32Window owner, String msg)
{
MessageBox.Show(owner, msg, Caption+ " - " + "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Issue :
Cross-thread operation not valid:Control 'MainPage' accessed from a thread other than the thread it was created on.