public Fire ( object o, System args ) : bool | ||
o | object | |
args | System | |
Результат | bool |
public void Test0() { FireOnceEvent feo = new FireOnceEvent(); int[] fired = new int[1]; fired[0] = 0; feo.Add(delegate(object o, EventArgs args) { fired[0] = fired[0] + 1; }); Assert.IsTrue(feo.Fire(null, null), "First fire test"); Assert.IsFalse(feo.Fire(null, null), "Second fire test"); Assert.IsFalse(feo.Fire(null, null), "Second fire test"); Assert.IsFalse(feo.Fire(null, null), "Second fire test"); Assert.AreEqual(fired[0], 1, "Fire event test 2"); }
/* ********************************************** * Here all the methods */ /** * Once this method is called, and the queue is emptied, * all future Dequeue's will throw exceptions * @return true if this is the first time Close was called */ public virtual bool Close() { if (0 == Interlocked.Exchange(ref _closed, 1)) { _close_event.Fire(this, null); return(true); } #if BRUNET_DEBUG Console.Error.WriteLine("Close set"); #endif return(false); }
public void Test0() { FireOnceEvent feo = new FireOnceEvent(); int[] fired = new int[1]; fired[0] = 0; feo.Add( delegate(object o, EventArgs args) { fired[0] = fired[0] + 1; }); Assert.IsTrue( feo.Fire(null, null), "First fire test" ); Assert.IsFalse( feo.Fire(null, null), "Second fire test" ); Assert.IsFalse( feo.Fire(null, null), "Second fire test" ); Assert.IsFalse( feo.Fire(null, null), "Second fire test" ); Assert.AreEqual(fired[0], 1, "Fire event test 2"); }
/** * Subclasses call this to fire the finish event * @return true if this is the first time this method is called */ protected bool FireFinished() { return(_finish_event.Fire(this, null)); }