1 Use Timer C# ; Lambda delegates

/// <summary> /// Wrapper for a one use timer. /// </summary> /// <param name="ms">The amount of time [in MS] to wait before doing the action.</param> /// <param name="voidPtr">The void* to use inside the timer.</param> public static void OneUseTimer(int ms, Action voidPtr) { var timer = new Timer(); timer.Tick += new EventHandler( (obj,evnt) => { voidPtr.Invoke(); ((Timer)obj).Stop(); }); timer.Interval = ms; timer.Start(); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.