Пример #1
0
        private async Task <bool> WeaveAsync(IPacketWriter host, IPacketWriter slot1, long slot1Id)
        {
            // Chuyen bang chu.
            try {
                host.PacketReceived += OnPacketReceived;
                var p0 = await host.Swap(slot1Id);

                if (p0 == null)
                {
                    return(false);
                }
            } finally {
                host.PacketReceived -= OnPacketReceived;
            }
            // FIXME: Kiểm tra có tạo được không?

            //thu hoach
            try {
                var tasks = new List <Task <Packet> >();
                tasks.Add(slot1.Collect((int)numericUpDown1.Value));

                var p2s = await Task.WhenAll(tasks);

                return(true);
            } finally {
                hostingTeamId = NoTeam;
            }
        }