.Net Thread Safety
Any future posts regarding thread safe calls will go here.
C#: (field)
//place in an event handling label, on edit, click, update, etc if(label1.InvokeRequired) { label1.Invoke(new MethodInvoker(delegate { label1.text = "value"; } )); } else { label1.text = "value"; }
C#: (singleton)
public sealed class ObjType { private static ObjType _ObjInstance; private static readonly object objlock; ObjType() { _ObjInstance=null; objlock = new object(); } public static ObjType ObjInstance { get { lock (objlock) { if (_ObjInstance==null) { _ObjInstance= new Singleton(); } return _ObjInstance; } } } }
Posted on January 13, 2011, in Programming & Development and tagged .net, c#, call, cores, microsoft, multi core, multi thread, multithreading, safe, thread, timers, vb, web. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0