コード例 #1
0
 /// <summary>
 /// Call the Function. Will only work once. Calling this twice will result in a exception
 /// </summary>
 public TRresult Call()
 {
     lock (me) {
         me = null;
         return(a());
     }
 }
コード例 #2
0
        /// <summary>
        /// Returns a new Call once Function that can be reset using the returned Action
        /// </summary>
        public static Tuple <CallOnceFunction <TRresult>, Action> CreateWithReset(Func <TRresult> call)
        {
            var r = new CallOnceFunction <TRresult>(call);

            return(new Tuple <CallOnceFunction <TRresult>, Action>(r, () => r.me = r));
        }
コード例 #3
0
 /// <summary>
 /// Creates a new CallOnceFunction
 /// </summary>
 /// <param name="call">Function that should only be called once</param>
 public CallOnceFunction(Func <TRresult> call)
 {
     me = this;
     a  = call;
 }