Exemplo n.º 1
0
        //16 超时发送
        static async Task Worker16()
        {
            chan <int> chan = chan <int> .make(0);//无缓存

            generator.children children = new generator.children();
            children.go(async delegate()
            {
                for (int i = 0; ; i++)
                {
                    chan_send_wrap res = await chan.timed_send(2000, i);
                    if (res.state == chan_state.overtime)
                    {
                        Log($"send 超时");
                        break;
                    }
                    await generator.sleep(1000);
                }
            });
            children.go(async delegate()
            {
                for (int i = 0; i < 3; i++)
                {
                    chan_recv_wrap <int> res = await chan.receive();
                    Log($"recv0 {res.msg}");
                }
            });
            await children.wait_all();
        }