UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Passing Data From One Thread To Another    
 
   
adamlevine
post Mar 21 2018, 10:32 PM
Post#1


Utter Spammer
Posts: 4
Joined: 21-March 18



Passing data prom one thread to another

Hi,
I have created a process that's runing a thread that open some windows form, now i want that other
running threads from the same process will be able to pass data to this windows form or even close it or reopen it.

The Windows form GUI is always in use of the end users so i cant lock.
what is the best way to implement it in c# ? i would like a short example, thanks.
Go to the top of the page
 
jleach
post Mar 22 2018, 07:01 AM
Post#2


UtterAccess Editor
Posts: 9,938
Joined: 7-December 09
From: Staten Island, NY, USA


There's no simple example that can be given: threading (and sharing data between threads) is a complex subject. Especially if that data is mutable - you're working in some ugly territory and there's a fair bit of background theory you should be aware of. Multithreading is rife with pitfalls and subtleties.

I'm not sure which UI framework you're using (WinForms, WPF, Xamarin, etc?), but generally speaking take a look at Invoke and BeginInvoke or Task.Run. There's many other ways to do it, but I do suggest some background reading on general threading concepts so you're not blindly walking into dangerous territory (there's entire books devoted to the subject...).
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    18th November 2018 - 03:48 PM