我已经通过this SO question但它没有帮助。InvalidOperationException - 对象当前正在其他地方使用
这里的情况是不同的。我正在使用Backgroundworkers。第一BackgroundWorker的开始上的用户图像输入和内部firstbackgroundworker_runworkercompleted()我使用调用其他3个backgroundworkers
algo1backgroundworker.RunWorkerAsync();
algo2backgroundworker.RunWorkerAsync();
algo3backgroundworker.RunWorkerAsync();
操作这是每个码:
algo1backgroundworker_DoWork()
{
Image img = this.picturebox.Image;
imgclone = img.clone();
//operate on imgclone and output it
}
algo2backgroundworker_DoWork()
{
Image img = this.picturebox.Image;
imgclone = img.clone();
//operate on imgclone and output it
}
类似操作在其他实现ALGO * backgrougrondworker_doWork()。
现在有时我得到“InvalidOperationException - 对象目前正在其他地方使用”。它非常武断。我有时在algo1backgroundworker_DoWork中,有时在algo2backgroundworker_DoWork中,有时在Application.Run(new myWindowsForm())中得到这个;
我不知道发生了什么。