当前位置: 首页>>代码示例>>C#>>正文


C# nsIRequest.cancel方法代码示例

本文整理汇总了C#中nsIRequest.cancel方法的典型用法代码示例。如果您正苦于以下问题:C# nsIRequest.cancel方法的具体用法?C# nsIRequest.cancel怎么用?C# nsIRequest.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nsIRequest的用法示例。


在下文中一共展示了nsIRequest.cancel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnStateChange

		public void OnStateChange (nsIWebProgress progress, nsIRequest request, Int32 status, UInt32 state)
		{
			if (!owner.created)
				owner.created = true;

#if debug
			//OnGeneric ("OnStateChange");

			System.Text.StringBuilder s = new System.Text.StringBuilder ();
			if ((state & (uint) StateFlags.Start) != 0) {
				s.Append ("Start\t");
			}
			if ((state & (uint) StateFlags.Redirecting) != 0) {
				s.Append ("Redirecting\t");
			}
			if ((state & (uint) StateFlags.Transferring) != 0) {
				s.Append ("Transferring\t");
			}
			if ((state & (uint) StateFlags.Negotiating) != 0) {
				s.Append ("Negotiating\t");
			}
			if ((state & (uint) StateFlags.Stop) != 0) {
				s.Append ("Stop\t");
			}
			if ((state & (uint) StateFlags.IsRequest) != 0) {
				s.Append ("Request\t");
			}
			if ((state & (uint) StateFlags.IsDocument) != 0) {
				s.Append ("Document\t");
			}
			if ((state & (uint) StateFlags.IsNetwork) != 0) {
				s.Append ("Network\t");
			}
			if ((state & (uint) StateFlags.IsWindow) != 0) {
				s.Append ("Window\t");
			}
			Console.Error.WriteLine (s.ToString ());
#endif

			bool _start = (state & (uint) StateFlags.Start) != 0;
			bool _negotiating = (state & (uint) StateFlags.Negotiating) != 0;
			bool _transferring = (state & (uint) StateFlags.Transferring) != 0;
			bool _redirecting = (state & (uint) StateFlags.Redirecting) != 0;
			bool _stop = (state & (uint) StateFlags.Stop) != 0;
			bool _request = (state & (uint) StateFlags.IsRequest) != 0;
			bool _document = (state & (uint) StateFlags.IsDocument) != 0;
			bool _network = (state & (uint) StateFlags.IsNetwork) != 0;
			bool _window = (state & (uint) StateFlags.IsWindow) != 0;

			if (_start && _request && _document && !calledLoadStarted) {
				nsIDOMWindow win;
				progress.getDOMWindow (out win);
				nsIChannel channel = (nsIChannel) request;
				nsIURI uri;
				channel.getURI (out uri);
				if (uri == null)
					currentUri = "about:blank";
				else {
					AsciiString spec = new AsciiString (String.Empty);
					uri.getSpec (spec.Handle);
					currentUri = spec.ToString ();
				}

				calledLoadStarted = true;
				LoadStartedEventHandler eh = (LoadStartedEventHandler) (owner.Events [WebBrowser.LoadStartedEvent]);
				if (eh != null) {

					AsciiString name = new AsciiString (String.Empty);
					win.getName (name.Handle);

					LoadStartedEventArgs e = new LoadStartedEventArgs (currentUri, name.ToString ());
					eh (this, e);
					if (e.Cancel)
						request.cancel (2152398850); //NS_BINDING_ABORTED
				}
				return;

			}

			if (_document && _request && _transferring) {
				nsIDOMWindow win;
				progress.getDOMWindow (out win);
				nsIChannel channel = (nsIChannel) request;
				nsIURI uri;
				channel.getURI (out uri);
				if (uri == null)
					currentUri = "about:blank";
				else {
					AsciiString spec = new AsciiString (String.Empty);
					uri.getSpec (spec.Handle);
					currentUri = spec.ToString ();
				}

				nsIDOMWindow topWin;
				win.getTop (out topWin);
				if (topWin == null || topWin.GetHashCode () == win.GetHashCode ()) {
					owner.Reset ();
					nsIDOMDocument doc;
					win.getDocument (out doc);
					if (doc != null)
//.........这里部分代码省略.........
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:Callback.cs


注:本文中的nsIRequest.cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。