本文整理汇总了C#中System.Runtime.Remoting.Contexts.Context.DoCallBack方法的典型用法代码示例。如果您正苦于以下问题:C# Context.DoCallBack方法的具体用法?C# Context.DoCallBack怎么用?C# Context.DoCallBack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.Remoting.Contexts.Context
的用法示例。
在下文中一共展示了Context.DoCallBack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDoCallback
public void TestDoCallback ()
{
otherCtx = cbo.GetContext ();
Assert.IsTrue (Thread.CurrentContext != otherCtx, "New context not created");
otherCtx.DoCallBack (new CrossContextDelegate (DelegateTarget));
}
示例2: TestDatastore
public void TestDatastore ()
{
otherCtx = cbo.GetContext ();
slot = Context.AllocateDataSlot ();
LocalDataStoreSlot namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
LocalDataStoreSlot namedSlot2 = Context.GetNamedDataSlot ("slot2");
Context.SetData (slot, "data");
Context.SetData (namedSlot1, "data1");
Context.SetData (namedSlot2, "data2");
otherCtx.DoCallBack (new CrossContextDelegate (CheckOtherContextDatastore));
Assert.IsTrue (Context.GetData (slot).Equals ("data"), "Wrong data 1");
Assert.IsTrue (Context.GetData (namedSlot1).Equals ("data1"), "Wrong data 2");
Assert.IsTrue (Context.GetData (namedSlot2).Equals ("data2"), "Wrong data 3");
try
{
namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
Assert.Fail ("Exception expected");
}
catch {}
Context.FreeNamedDataSlot ("slot1");
Context.FreeNamedDataSlot ("slot2");
try
{
namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
}
catch
{
Assert.Fail ("Exception not expected");
}
Context.FreeNamedDataSlot ("slot1");
}