Hello, First off, my apologies if I did miss-understand your question, since english is not my main (neither my first) language.
I think you are trying to syncronize the access to a given UI component being acceded by two threads, and I'm taking the assumption that you use WinForms and .NET, probably C# or VB. If this is the case, you must know that in normal condition only the creator thread is allowed to access a GUI component. So, you must tell the creator thread to do the task and return any needed values. We often do this with BeginInvoke of the Form, doing this the calls are queued and executed in an async and thread safety way. ---- Besides that you mention something about a file... well, you can choose to share access to a file with filestream, then handle the exceptions, and check for the return value, that will help you sync to your file. Also inside the file you can lock areas with the Lock method of the same class (unlock with Unlock >-<). If your requirements are different, you may start by just using a lock statement, remember to lock on a private object (no valuetype) . Private for safety. This what's more often done, not always the best, but always functional. And you know, what they say.. test, test, test. There are other method to sync, but I think this fits you as (I think) you are new to the subject. Anyways, if you need to share info, virtual variables and threadstatic values are safe to read (the last one is not shared across threads :P). You can take an aproach to your own handling, if you write a thread safe (with lock, may be) method that takes requests and stores them (returns fast), and then have a walker thread that runs the requests... in that case a ManualResetEvent may do. ------ Let me mention something else, take care of storing references indefinately, I mean because of problems with the GC. please take a look to: http://www.codeproject.com/KB/cs/WeakEvents.aspx http://www.codeproject.com/KB/cs/WeakDelegateSet.aspx (review the code if you get the time, I have strong respect to his autor). Those are eye openers, I swear. ------ Documentation here: (begininvoke) http://msdn.microsoft.com/en-us/library/0b1bf3y3.aspx (async callers) http://msdn.microsoft.com/en-us/library/2e08f6yc.aspx (manual reset event) http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent(VS.71).aspx (threading tutorial) http://msdn.microsoft.com/en-us/library/aa645740(VS.71).aspx (delegates) http://msdn.microsoft.com/en-us/library/ms173171(VS.80).aspx On 17 mar, 00:12, "BIJU A.J" <[email protected]> wrote: > Hi > > thanks in advance > I want to know the synchronization and asynchronization of threads.How to > share one function to two thread objects.When click first Thread Start ,the > text file content display as a block in first text box. If click the second > thread start,if it syncronization, the first block in first text box and > second block in second text box and son. > > if can pls send the any idea. > > thanks , > > Biju
