示例#1
0
        private async System.Threading.Tasks.Task InitializeNetworkConnection()
        {
            state.Text = "Looking for host";
            var discoveredHost = await this.WaitForDiscoverHostAsync(TimeSpan.FromSeconds(2));

            if (discoveredHost == null)
            {
                state.Text = "host not found. setting up host";
                try
                {
                    discoveredHost = InitializeHost();
                    await networkService.ConnectAsync(discoveredHost);

                    isHost      = true;
                    isConnected = true;
                }
                catch (Exception e)
                {
                    state.Text = "there is already a local host";
                    Trace.WriteLine(e.Message);
                }
            }
        }