private async void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            // Create resolver and add event handlers
            var resolver = new PeerNameResolver();

            resolver.ResolveProgressChanged += new EventHandler <ResolveProgressChangedEventArgs>(resolver_ResolveProgressChanged);
            resolver.ResolveCompleted       += new EventHandler <ResolveCompletedEventArgs>(resolver_ResolveCompleted);

            // Prepare for new peers
            peerList.Clear();
            RefreshButton.IsEnabled = false;

            // Resolve unsecured peers asynchronously
            resolver.ResolveAsync(new PeerName("0.P2P Sample"), 1);

            await Task.Delay(5000); // to fire the Completed event latest after 5 seconds

            resolver.ResolveAsyncCancel(1);
        }
Пример #2
0
        private async void RefreshButton_OnClick(object sender, RoutedEventArgs e)
        {
            // Создание распознавателя и добавление обработчиков событий
            var resolver = new PeerNameResolver();

            resolver.ResolveProgressChanged += Resolver_ResolveProgressChanged;
            resolver.ResolveCompleted       += Resolver_ResolveCompleted;

            // Подготовка новых равноправных участников
            _peerList.Clear();
            RefreshButton.IsEnabled = false;

            // Распознавание незащищенных равноправных участников асинхронным образом
            resolver.ResolveAsync(new PeerName("0.P2P Sample"), 1);

            await Task.Delay(5000); // NOTE: Для вызова события ResolveCompleted после максимум 5 секунд

            resolver.ResolveAsyncCancel(1);
        }
Пример #3
0
 public void CancelLookup(PeerName peerName)
 {
     _resolver = new PeerNameResolver();
     _resolver.ResolveAsyncCancel(peerName);
 }