System.Net.WebConnection.Abort C# (CSharp) Method

Abort() private method

private Abort ( object sender, EventArgs args ) : void
sender object
args EventArgs
return void
		void Abort (object sender, EventArgs args)
		{
			lock (this) {
				lock (queue) {
					HttpWebRequest req = (HttpWebRequest) sender;
					if (Data.request == req) {
						if (!req.FinishedReading) {
							status = WebExceptionStatus.RequestCanceled;
							Close (false);
							if (queue.Count > 0) {
								Data.request = (HttpWebRequest) queue.Dequeue ();
								SendRequest (Data.request);
							}
						}
						return;
					}

					req.FinishedReading = true;
					req.SetResponseError (WebExceptionStatus.RequestCanceled, null, "User aborted");
					if (queue.Count > 0 && queue.Peek () == sender) {
						queue.Dequeue ();
					} else if (queue.Count > 0) {
						object [] old = queue.ToArray ();
						queue.Clear ();
						for (int i = old.Length - 1; i >= 0; i--) {
							if (old [i] != sender)
								queue.Enqueue (old [i]);
						}
					}
				}
			}
		}

Usage Example

Esempio n. 1
0
            public void Abort(object sender, EventArgs args)
            {
                WebConnection webConnection = ((HttpWebRequest)sender).WebConnection;

                if (webConnection == null)
                {
                    webConnection = Connection;
                }
                webConnection.Abort(sender, args);
            }
All Usage Examples Of System.Net.WebConnection::Abort