Last post Jun 29, 2015 06:37 AM by gerrylowry
Jun 26, 2015 10:38 AM|jjmonty|LINK
Jun 26, 2015 10:51 AM|PatriceSc|LINK
No it just call Dispose being the scene which is not threadsafe. Try perhaps
Some more context could help to better understand your concerns (in particular it seems the OP for the above thread tried to implement a solution for those consuming his class just in case. I'm not sure it's the best option as 1) those guys could implement
their own not knowing it is done already plus they might have some other need or whatever and they might be best placed to do that...)
Jun 26, 2015 01:00 PM|jjmonty|LINK
I wasn't clear about the using statement in threaded methods...that's why I asked hoping for a gracious and empathetic answer from someone who wants to help a person in need. Please withhold your comments if you are so nasty, man. Lighten up...people come
to these boards for help.
Jun 26, 2015 01:12 PM|PatriceSc|LINK
It was perhaps a bit rought but still gerylowry has a point.
As I tried myself to explain seeing a simple question with a yes/no answer on a complex topic such as thread safety is a bit "suspect". If you are able to study this matter but don't find by yourself what the "using" statement is and that Dispose is not
thread safe, then it's likely you are trying do something which is not perhaps well defined yet in which case some more context could be helpfull.
If you are trying to achieve some particular goal it might be best to post directly about that final goal...
Jun 29, 2015 06:37 AM|gerrylowry|LINK
In multi-threaded applications where multiple threads make calls to the methods of a single object,
it is necessary that those calls be synchronized. If code is not synchronized, then one thread might interrupt another thread and the object could be left in an invalid state. A class whose members are protected from such interruptions
is called thread-safe.
jjmonty, likely you need to explicitly protect your using statement and the code that it wraps.
https://msdn.microsoft.com/en-us/library/yh598w02.aspx " using Statement (C# Reference)"
jjmonty, if you want to ensure thread safety, you need to consider design patterns like the singleton as well as c#'s lock statement.
BOTTOM LINE: generally, thread safety in c# is not automatic when you are attempting to write multi-threaded code.
https://msdn.microsoft.com/en-us/library/ms173179.aspx "Thread Synchronization (C# and Visual Basic)"
https://msdn.microsoft.com/en-us/library/c5kehkcz.aspx "lock Statement (C# Reference)"