Ejemplo n.º 1
0
 public SoftDebuggerStartInfo(SoftDebuggerStartArgs startArgs)
 {
     if (startArgs == null)
     {
         throw new ArgumentNullException("startArgs");
     }
     this.StartArgs = startArgs;
 }
 public SoftDebuggerStartInfo(SoftDebuggerStartArgs startArgs)
 {
     if (startArgs == null)
         throw new ArgumentNullException ("startArgs");
     this.StartArgs = startArgs;
 }
		void EndLaunch ()
		{
			HideConnectionDialog ();
			if (connectionHandle != null) {
				if (startArgs != null && startArgs.ConnectionProvider != null) {
					startArgs.ConnectionProvider.CancelConnect (connectionHandle);
					startArgs = null;
				} else {
					VirtualMachineManager.CancelConnection (connectionHandle);
				}
				connectionHandle = null;
			}
		}
		void StartConnection (SoftDebuggerStartInfo dsi)
		{
			this.startArgs = dsi.StartArgs;
			
			RegisterUserAssemblies (dsi);
			
			if (!String.IsNullOrEmpty (dsi.LogMessage))
				LogWriter (false, dsi.LogMessage + "\n");
			
			AsyncCallback callback = null;
			int attemptNumber = 0;
			int maxAttempts = startArgs.MaxConnectionAttempts;
			int timeBetweenAttempts = startArgs.TimeBetweenConnectionAttempts;
			callback = delegate (IAsyncResult ar) {
				try {
					string appName;
					VirtualMachine vm;
					startArgs.ConnectionProvider.EndConnect (ar, out vm, out appName);
					this.remoteProcessName = appName;
					ConnectionStarted (vm);
					return;
				} catch (Exception ex) {
					attemptNumber++;
					if (!ShouldRetryConnection (ex, attemptNumber)
						|| !startArgs.ConnectionProvider.ShouldRetryConnection (ex)
						|| attemptNumber == maxAttempts
						|| Exited)
					{
						OnConnectionError (ex);
						return;
					}
				}
				try {
					if (timeBetweenAttempts > 0)
						System.Threading.Thread.Sleep (timeBetweenAttempts);
					ConnectionStarting (startArgs.ConnectionProvider.BeginConnect (dsi, callback), dsi, false, 0);
				} catch (Exception ex2) {
					OnConnectionError (ex2);
				}
			};
			//the "listening" value is never used, pass a dummy value
			ConnectionStarting (startArgs.ConnectionProvider.BeginConnect (dsi, callback), dsi, false, 0);
		}