当前位置: 首页>>代码示例>>C#>>正文


C# Communicator.Abort方法代码示例

本文整理汇总了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();
    }
开发者ID:jmhal,项目名称:MPI.NET,代码行数:41,代码来源:NonblockingTest.cs


注:本文中的Communicator.Abort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。