Esempio n. 1
0
		private Deferred GetDummyData(int x)
		{
			Deferred d = new Deferred();
			ReactorBase.Reactor.CallLater(d, x*3, 2000);
			return d;
		}
Esempio n. 2
0
		public void TestDefferedSystem()
		{
			Deferred d = GetDummyData(5);
			d.AddCallback(new PrintDataDelegate(PrintData));
			d.AddErrback(new PrintDataDelegate(PrintDataError));
			Deferred dToChain = new Deferred();
			d.ChainDeferred(dToChain);
			dToChain.AddCallback(new PrintDataDelegate(PrintDataSuccess));
			
			d = new Deferred();
			d.AddCallback(new StopReactorDelegate(StopReactor));
			_reactor.CallLater(d, null, 4000);
			_reactor.Run();
			Assert.IsTrue(this._testDeferredSuceeded);
		}
Esempio n. 3
0
		/// <summary>
		/// Chain another Deferred to this Deferred.
		/// This method adds callbacks to this Deferred to call d's callback or
		/// errback, as appropriate. 
		/// 
		/// When you chain a deferred d2 to another deferred d1 with
		/// d1.ChainDeferred(d2), you are making d2 participate in the callback
		/// chain of d1. Thus any event that fires d1 will also fire d2.
		/// However, the converse is B{not} true; if d2 is fired d1 will not be
		/// affected.
		/// </summary>
		/// <param name="deferred">
		/// A <see cref="Deferred"/>
		/// </param>
		public void ChainDeferred(Deferred deferred)
		{
			this.AddCallbacks(new CallBackDelegate(deferred.Callback), new ErrBackDelegate(deferred.Errback), new object[]{}, new object[]{});
		}