BeginAnnouncingAsync() public method

Sending an announcement every 3 seconds until the token is cancelled.
public BeginAnnouncingAsync ( int port, CancellationToken token ) : Task
port int
token System.Threading.CancellationToken Token.
return Task
示例#1
0
		public async Task Announce_CancelBefore ()
		{
			var cts = new CancellationTokenSource();
			var announcer = new UdpBroadcast();
			cts.Cancel();
			var task = announcer.BeginAnnouncingAsync (12345, cts.Token);
			await Asserts.IsCancelled(task);
		}
示例#2
0
		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) {

			}
		}