Questions tagged [cross-thread]

28 questions
5
votes
1 answer

Getting thread access exceptions on OnCollectionChanged after Creators Update

In my program, I have an abstract class ObservableKeyedCollection that inherits from KeyedCollection and also implements INotifyCollectionChanged. A realisation of this abstract class is bound to a ListBox. In this ListBox,…
tethered.sun
  • 87
  • 3
  • 14
2
votes
1 answer

How to cross thread calls in native C++ (call back on main thread)

I am implementing the C++ mobile apps to call some process which taking some times to make it done, but I need my apps main thread is still running without any blocking. Question: Is there any library that could just call runOnUIThread to get back…
Oktaheta
  • 528
  • 4
  • 16
2
votes
2 answers

How to use multiple background workers in a loop in which to start new work each iteration for each background worker in C#

I need to use 4 background workers to move 4 objects on a specific coordinates in parallel i.e. start them together and stop them together. I wrote a loop to loop 50 times and each time I need to start the workers and after they complete their work…
Rose
  • 249
  • 1
  • 15
1
vote
0 answers

Cross-thread operation after using EventHandler

I needed to create an event in another class, so I've used an EventHandler and this works fine, however now in my main class form, when I try to use any controls I get: Cross-thread operation not valid So after researching I can…
chasher
  • 121
  • 10
1
vote
1 answer

C# DataBinding / Update DynamicObject property from another thread

Previously I was working on an implementation of DynamicObject data binding (see Dynamic object two way data binding), and the solution works great. Since then I have run into the need to be able to update the values from different threads it seems…
Aaron Murray
  • 1,816
  • 3
  • 19
  • 33
1
vote
0 answers

CrossThread Exception on Control's Parent

TabControl _tabControl; TabPage _tabPage; ListView _listView; /// this._tabControl.Controls.Add(this._tabPage); this._tabPage.Controls.Add(this._listView) /// private void UpdateListView() { If (_listView.InvokeRequired) { …
0
votes
0 answers

Why creating a new form and showing it in another thread does not raise cross-thread exception in Visual Studio?

Say I have a Windows form and then click a button to start a new thread. If in that new thread I change something about the current form, like its background color, Visual Studio will raise an invalid operation exception as I have crossed threads…
0
votes
1 answer

CommonOpenFileDialog - Cross-thread operation not valid after call from UI thread

So I'm using the CommonOpenFileDialog from the windowsAPICodepack. In a previous version of the application I'm writing, the CommonOpenFileDialog worked without any problems. In the current version targeted at a higher version of the .Net Framework,…
Thomas
  • 21
  • 2
0
votes
2 answers

How to let the code run smoothly using timers and different threads

I'm trying to prevent the GUI from freezing, because of a low timer interval and too much to process in the Timer.Tick event handler. I've been googling a while and I understood that I cannot update UI from any other thread other than the UI…
Mattia
  • 172
  • 3
  • 14
0
votes
0 answers

Why can my winform cross-thread access without error or exception

Recently, I tried to use multithreading in winform, and I copied a piece of code online. Unexpectedly, this code runs normally on my computer, and there is no cross-thread access exception. I want to figure out why. I use the .net4.0 csc compiler to…
0
votes
0 answers

Cross Thread operation on Rich Text Box Selection actions

I've created a custom Rich Text box in my .Net winform application, and I'm facing a strange issue. The goal is append Text to the rich text box with a specific formating, all of this within another thread. For this I've created delegates callback.…
TmZn
  • 347
  • 4
  • 15
0
votes
0 answers

.net add handler multithread

I’m tying myself up in knots here with multithread in vb. I have a working program that I subscribe to 4 events using the add handler address of and point to a function on my main form. I have 4 separate functions that all do exactly the same thing…
0
votes
1 answer

how to safe call a control from another thread using Timers.Timer

I read various posts, and made a practice project, but it does not works. The form have a button and a text box with a default text 'Updated 0 times'. On button click starts the timer and each time update the text with the number of times the text…
0
votes
0 answers

Cross-thread operation error occur when using backgroudWorker C#

I want to display a progress bar when fetching data to textbox using backgroundWorker. But when debugging, it raised an the following error: I have read the similar case but It cannot solve my problem. System.InvalidOperationException:…
Cát Tường Vy
  • 398
  • 4
  • 27
0
votes
1 answer

DataGrid not creating Rows when its ItemSource is updated & Sometimes Duplicate entries

We are making a WPF app that uses a FileSystemWatcher to monitor changes to a directory of the user's choice and outputs the changes onto a DataGrid. In my MainWindow() constructor, I bind my DataGrid to a List I call _eventList via…
1
2