L
L
Lev Fedorov2018-04-17 03:48:39
Programming
Lev Fedorov, 2018-04-17 03:48:39

Invalid operation in multiple threads?

I can't figure out what the code is asking me to do. Wrote an event handler for a button click. When the button is pressed, everything works. As soon as I transferred this code to the event of receiving data from the COM port, it swears at it ->

An "System.InvalidOperationException" exception occurred in System.Windows.Forms.dll ("Invalid multi-threaded operation: Attempted to access control 'dataGridView1' from a thread other than the thread it was created on.")

5ad544642e8dc706709640.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ananiev, 2018-04-17
@blvckheart0

You cannot work with graphic elements from another thread. Use Invoke.
https://msdn.microsoft.com/en-us/library/zyzhdc6b(...

S
Stanislav Makarov, 2018-04-17
@Nipheris

Why does windwos forms form and timers freeze?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question