Note that there are some explanatory texts on larger screens.

plurals
  1. POThe calling thread cannot access this object (rewrited but same error)
    text
    copied!<p>I have a MainFrame window with imageViewer control on it. Also there is my dll which calculates changes for the image all was working fine before I decided to add ProgressDialog.(( The Idea was - firstly I am loading the image via dll to main frame (this still OK). Then if user clicks button then show ProgressDialog and in worker.DoWork create new image via the same dllwrapper class (I am using "new") All seems to be ok but when i am trying to set my currentImage property of imageviewer control (this is nothing more then setter for Image)it show me this error! This is the code of my userButtonClickHandler from where I am launching ProgressDialog:</p> <pre><code>void OnThumbnailClick(object sender, RoutedEventArgs e) { pd = new ProgressDlg(); pd.Cancel += CancelProcess; int max = 1000; System.Windows.Threading.Dispatcher pdDispatcher = pd.Dispatcher; worker = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; LibWrap lwrap = new LibWrap();//!NEW instance for dll wrapper! worker.DoWork += delegate(object s, DoWorkEventArgs args) { imageViewer.CurrentImage = lwrap.engine2(BitmapFrame.Create(MyPrj.App.draggedImage));//ERROR IS HERE!!!//The calling thread cannot access this object because a different thread owns it. //what process?? }; worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { pd.Close(); }; worker.RunWorkerAsync(); pd.ShowDialog(); } </code></pre> <p>There is function from the same MainFrame class for canceling (There is OK too)</p> <pre><code>void CancelProcess(object sender, EventArgs e) { worker.CancelAsync(); } </code></pre> <p>This is class for ProgressDlg (it has nothing more then progress bar and cancel button):</p> <pre><code>public partial class ProgressDlg : Window { public ProgressDlg() { InitializeComponent(); } public string ProgressText { set { this.lblProgress.Content = value; } } public int ProgressValue { set { this.progress.Value = value; } } public event EventHandler Cancel = delegate { }; private void btnCancel_Click(object sender, RoutedEventArgs e) { Cancel(sender, e); } } } </code></pre> <p>I am working with this problem for (almost) two days and still couldn't find the solution. Help me please if you have an idea.</p> <p>1 UPDATE It seems to me that you was right about this threads - when I am trying to load previously loaded(initial) image (from the main thread) -it loads OK but if I am trying libWrap it fails due to processes conflict!</p> <pre><code>worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { imageViewer.Width = 1000;//work! imageViewer.CurrentImage = MyPrj.App.draggedImage;//Work! imageViewer.CurrentImage = lwrap.engine2(BitmapFrame.Create(MyPrj.App.draggedImage));//Fail =(! } </code></pre> <p>2 UPDATE I have tried this construction OnThumbnailClick </p> <pre><code>Application.Current.MainWindow.Dispatcher.BeginInvoke(new Action(() =&gt; { imaeViewer.CurrentImage = lwrap.engine2(BitmapFrame.Create(FXPhotoStudio.App.draggedImage)); } </code></pre> <p>This caused same error/ Perhaps it will be correct to pass this value in MainThread (UI)? But I have no idea how.( I couldnot use serializers - becouse it is rapidly calling operation and this images are temporary/</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload