I am working in wpf application. i want to call the print method till when i click stop button. So that case i have used in thread concept while i was getting This error 'The calling thread cannot access this object because a different thread owns it' because also multiple thread run in that method so i handled this type of solution. my print method called in PrintElement like this;

public static PrintLable PrintElement()
{
    PrintLable printLable= null;
    Application.Current.Dispatcher.Invoke(
       System.Windows.Threading.DispatcherPriority.Normal, new Action(
          delegate()
          {
              PrintElement printLable = new PrintElement();
              // Initialize your PrintElement here
          }));
    return printLable;
}

0 comments

Related Posts Plugin for WordPress, Blogger...