/// <summary> /// Start a session to debug an application on the Meadow /// </summary> /// <param name="port">The port to use for the debugging proxy</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> for cancelling the operation</param> /// <returns>A running <see cref="DebuggingServer"/> that is available for connections</returns> public async Task <DebuggingServer> StartDebuggingSessionAsync(int port, CancellationToken cancellationToken) { await MonoEnableAsync(cancellationToken : cancellationToken); await _meadowDevice.StartDebuggingAsync(port, cancellationToken) .ConfigureAwait(false); await Task.Delay(1000, cancellationToken) .ConfigureAwait(false); await ReInitializeMeadowAsync(cancellationToken).ConfigureAwait(false); if (_meadowDevice == null) { throw new DeviceNotFoundException(); } var endpoint = new IPEndPoint(IPAddress.Loopback, port); var debuggingServer = new DebuggingServer(_meadowDevice, endpoint, Logger); await debuggingServer.StartListeningAsync(cancellationToken).ConfigureAwait(false); return(debuggingServer); }