/// <summary> /// Call the Action. Will only work once. Calling this twice will result in a exception /// </summary> public void Call() { lock (me) { me = null; a(); } }
/// <summary> /// Returns a new Call once Action that can be reset using the returned Action /// </summary> public static Tuple <CallOnceAction, Action> CreateWithReset(Action call) { var r = new CallOnceAction(call); return(new Tuple <CallOnceAction, Action>(r, () => r.me = r)); }
/// <summary> /// Creates a new CallOnceAction /// </summary> /// <param name="call">Action that should only be called once</param> public CallOnceAction(Action call) { me = this; a = call; }