Questions tagged [cross-thread]
38 questions
0
votes
0 answers
Is there a way to simplify the code for handling multiple cross-threaded exceptions?
I'm making a 1:N asynchronous chat program in C# Windows Form.
When the server connection was successful, an attempt was made to change the Enabled property of the Connect button to false.
A cross-thread exception was thrown at this…
user18024704
0
votes
0 answers
WinForms Tab Control Causing Cross-Thread Operation
This is the error I am receiving. I have a button on a winforms control (as depicted below). I have an async void method that is attached to the click event handler (as depicted below)
The issue that I am having is that this code runs perfectly…

Jeremy Buentello
- 133
- 9
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…

Girl Spider
- 330
- 2
- 6
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
- 258
- 7
- 25
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
- 399
- 5
- 16
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…

Paul Speirs
- 19
- 2
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…

user2150033
- 83
- 5
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
- 6
- 32
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…

Matthew Jett
- 57
- 9
0
votes
0 answers
Control.InvokeRequired - Subject to a race condition
I found a suggested solution to the cross-thread exception issue in another posting and have used it my code below, but I am finding it erratic at best. My tests indicate that it's correct operation is at the mercy of a race condition so I was…

BenevolentDeity
- 693
- 1
- 4
- 18
0
votes
1 answer
async/await debugging in WinForms: system.invalidoperationexception cross-thread operation not valid
When starting/running your aplication from within Visual Studio 2017 by Ctrl+F5 (Start Without Debugging) and using async/await for winforms' controls events processing. e.g., button click event processing, you can access these controls properties…

ShamilS
- 1,410
- 2
- 20
- 40
0
votes
1 answer
Error while dynamically creating toolStripMenuItem
I'm having the following issue: I have a config file and a listener over this file. When changed, triggers a method (createMenuAndItems), that modifies the toolStripMenuItem.
The method createMenuAndItems is called upon load of the Form and when the…

Lasmaty07
- 21
- 6
0
votes
2 answers
Cross-thread operation
I happen to get this Cross-Thread Error when trying to invoke a textbox from a different thread other than the main MMI Thread. I already understand why it happens.I would like your opinion about the way I am solving this.
I am using this because I…

Yaniv.M
- 3
- 2
0
votes
1 answer
Update ListView from a thread not the original thread in C#
I already know that to update control, I can use Invoke Action
progressBar1.Invoke(new Action(() => { progressBar1.Maximum = 0; }));
But that only work with property of control which are single data. Now I have a thread that need to change the list…

user3505230
- 33
- 8
-1
votes
1 answer
Using Task to Setup a DataGridView
I am using Task() to offload work during the start of my application. And it was working fine. And then it wasn't... If I've got it right, I am making a copy of 'SomeStatusradGridView'. Which means I should be fine, except I get the following…

Scooter
- 364
- 3
- 8