예제 #1
0
		public async Task Announce_CancelAfter ()
		{
			var cts = new CancellationTokenSource();
			var announcer = new UdpBroadcast();
			var task = announcer.BeginAnnouncingAsync (12345, cts.Token);
			cts.Cancel();
			await Asserts.IsCancelled(task);
		}
예제 #2
0
		public async Task Listen_CancelBefore ()
		{
			var cts = new CancellationTokenSource();
			var announcer = new UdpBroadcast();
			cts.Cancel();
			var task = announcer.BeginListeningAsync(cts.Token);
			await Asserts.IsCancelled(task);
		}
		async void SearchForServers ()
		{
			var announceListener = new UdpBroadcast ();
			announceListener.ServerFound += (o, e) => {
				if (!Servers.Contains (e)) {
					Servers.Add (e);
					serverTableView.ReloadData ();
				}
			};

			await announceListener.BeginListeningAsync(searchCancellation.Token).WaitOrCanceled();
		}
예제 #4
0
파일: Main.cs 프로젝트: alanmcgovern/tunez
		static async Task Initialize (CancellationToken token)
		{
			var catalog = await LoadCatalog (token);

			handler = new RequestHandler {
				Catalog = catalog
			};
			announcer = new UdpBroadcast ();

			try {
				await Task.WhenAll (new [] {
					handler.BeginListeningAsync (token),
					announcer.BeginAnnouncingAsync (handler.ListenPort, token)
				});
			} catch (OperationCanceledException) {

			}
		}