MrFile,
You will have to use the lock statement or the Monitor class (which is
what the lock statement uses) in order to protect access to this variable.
Whenever you read or write from this variable, it basically has to be
protected (since it is coming in on two separate threads). Locking the
access doesn't mean that it will deadlock, it just means it will block
access to that variable for the duration of what you are trying to do. As
long as you don't perform some very lenghty operations in the lock segment,
or call Enter on the Monitor class without calling Exit, you should be fine.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"MrFile" <we********@yahoo.com> wrote in message
news:9a**************************@posting.google.c om...
C#.Net question for everyone
I have a class that has a method that i run async from the Form.
This class has one field string called log. I need this since i have
an event that can write to it sometimes, and not only my async method.
Now im noticing this log seems to be updated by both of the running
threads. Is there any way to resolve this without locking the log
variable and therefore causing my thread to be locked up as well?