本文整理汇总了C#中Communicator.Abort方法的典型用法代码示例。如果您正苦于以下问题:C# Communicator.Abort方法的具体用法?C# Communicator.Abort怎么用?C# Communicator.Abort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Communicator
的用法示例。
在下文中一共展示了Communicator.Abort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCancellation
static void TestCancellation(Communicator comm)
{
int datum = comm.Rank;
int expectedDatum = (comm.Rank + comm.Size - 1) % comm.Size;
int[] intArrayRecvBuffer = new int[expectedDatum + 1];
string[] strArrayRecvBuffer = new string[expectedDatum + 1];
int[] intArraySendBuffer = new int[comm.Rank + 1];
string[] strArraySendBuffer = new string[comm.Rank + 1];
for (int i = 0; i <= comm.Rank; ++i)
{
intArraySendBuffer[i] = i;
strArraySendBuffer[i] = i.ToString();
}
// Test cancellation of receive requests
Request[] requests = new Request[4];
requests[0] = comm.ImmediateReceive<int>(Communicator.anySource, 0);
requests[1] = comm.ImmediateReceive<string>(Communicator.anySource, 1);
requests[2] = comm.ImmediateReceive(Communicator.anySource, 2, intArrayRecvBuffer);
requests[3] = comm.ImmediateReceive(Communicator.anySource, 3, strArrayRecvBuffer);
// Cancel all of these requests.
requests[0].Cancel();
requests[1].Cancel();
requests[2].Cancel();
requests[3].Cancel();
// Check that the requests were actually cancelled
for (int i = 0; i < 4; ++i)
{
if (!requests[0].Wait().Cancelled)
{
System.Console.Error.WriteLine("error: cancelled receive request "
+ i.ToString() + " not marked as cancelled");
comm.Abort(1);
}
}
comm.Barrier();
}