0

I am exporting a database in bacpac format using DacService object. This object has two events (Message and ProgressChanged) that can be used to show the operation progress

DacServices dacSvc = new DacServices(cnStr);
dacSvc.Message += new EventHandler<DacMessageEventArgs>(receiveDacServiceMessageEvent);
dacSvc.ProgressChanged += new EventHandler<DacProgressEventArgs>(receiveDacServiceProgessEvent);

private void receiveDacServiceProgessEvent(object sender, DacProgressEventArgs e)
{
    Console.WriteLine("{0} {1}", e.Message, e.Status);
}

private void receiveDacServiceMessageEvent(object sender, DacMessageEventArgs e)
{
    Console.WriteLine(e.Message.Message);
}

If I use this code and I try to write the Messages in a TextBox instead of Console I get this error:

Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on

I already try to use (withous success) the solution I found here Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on

skysurfer
  • 601
  • 1
  • 5
  • 15

0 Answers0