Пример #1
0
 /// <summary>
 /// Creates a new OauthHttpListener that will listen to the Url and will notify waiting threads 
 /// when oauth login has completed
 /// </summary>
 /// <param name="url">Url we want to listen to</param>
 /// <param name="waitForTokenHandle">instance to pass token back and to notify waiting threads</param>
 public OauthHttpListener(string url, WaitForToken waitForTokenHandle)
 {
     _listener = new HttpListener();
     _listener.Prefixes.Add(url);
     _waitForTokenHandle = waitForTokenHandle;
     _listener.Start();
     _listener.BeginGetContext(new AsyncCallback(BeginContextCallback), _listener);
 }
Пример #2
0
        /// <summary>
        /// Creates an instance of browser that will create a process with the default browser pointing to
        /// the Url passed.
        /// </summary>
        /// <param name="url">Url we want to open the browser with</param>
        /// <param name="waitForToken">token to notify if possible, if the user closes the browser</param>
        public Browser(string url, WaitForToken waitForToken)
        {
            var browserPath = GetBrowserPath();

            _proc = Process.Start(browserPath, GetBrowserArguments(browserPath, url));
            if (waitForToken != null &&
                _proc != null)
            {
                _proc.EnableRaisingEvents = true;
                _proc.Exited += (sender, e) => waitForToken.WaitHandle.Set();
            }
        }