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


C# BackgroundWorker.RunWorkASync方法代码示例

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


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

示例1: Build

		/// <summary>
		/// 构建项目
		/// </summary>
		/// <param name="filepath"></param>
		public virtual void Build(string filepath)
		{
			var builder = UpdatePackageBuilder.Instance;
			var project = AuProject.LoadFile(filepath);

			if (project == null)
			{
				BuilderFailed(null, new ApplicationException(SR.UnableOpenProject), null);
				return;
			}

			builder.AuProject = project;

			var bgw = new BackgroundWorker();
			bgw.DoWork += (s, e) => builder.Build(e);
			bgw.WorkFailed += (s, e) => BuilderFailed(project, e.Exception, builder.BuiltUpdateInfo);
			bgw.WorkCompleted += (s, e) => BuildSuccess(project, builder.Result, builder.BuiltUpdateInfo);
			bgw.WorkerProgressChanged += (s, e) => UpdateProgress(e.Progress);

			OnWorkerInitialized();
			bgw.RunWorkASync();
		}
开发者ID:ChenJasonGit,项目名称:FSLib.App.SimpleUpdater,代码行数:26,代码来源:BuilderInterfaceBase.cs

示例2: BeginCheckUpdateInProcess

		/// <summary>
		/// 开始检测更新
		/// </summary>
		/// <returns>返回是否成功开始检查</returns>
		/// <exception cref="System.InvalidOperationException"></exception>
		public bool BeginCheckUpdateInProcess()
		{
			var url = Context.UpdateInfoFileUrl;

			if (string.IsNullOrEmpty(url)) throw new InvalidOperationException(SR.Updater_AssemblyNotMarkedAsUpdateable);
			if (Context.IsInUpdating) return false;

			var bgw = new BackgroundWorker()
			{
				WorkerSupportReportProgress = true
			};
			bgw.DoWork += DownloadUpdateInfoInternal;
			bgw.WorkFailed += (s, e) =>
			{
				Context.IsInUpdating = false;
				Context.Exception = e.Exception;
				Trace.TraceWarning("检测更新信息失败:" + e.Exception.Message, e.Exception.ToString());
				OnError();
			};
			bgw.WorkCompleted += (s, e) =>
			{
				if (Context.UpdateInfo == null) return;

				Context.IsInUpdating = false;

				if (Context.CurrentVersionTooLow)
				{
					OnMinmumVersionRequired();
				}
				else if (!Context.HasUpdate)
				{
					OnNoUpdatesFound();
				}
				else OnUpdatesFound();

			};
			bgw.WorkerProgressChanged += (s, e) => OnOperationProgressChanged(e);
			Context.IsInUpdating = true;
			bgw.RunWorkASync();
			//启动外部清理进程。
			CleanTemp();

			return true;
		}
开发者ID:huguojunsy,项目名称:FSLib.App.SimpleUpdater,代码行数:49,代码来源:Updater.cs

示例3: BeginUpdate

		/// <summary>
		/// 开始进行更新
		/// </summary>
		internal void BeginUpdate()
		{
			var bgw = new BackgroundWorker() { WorkerSupportReportProgress = true };
			bgw.DoWork += UpdateInternal;
			bgw.WorkerProgressChanged += (s, e) => OnOperationProgressChanged(e);
			bgw.WorkFailed += (s, e) =>
			{
				Context.IsInUpdating = false;
				Context.Exception = e.Exception;
				Trace.TraceWarning("更新中断,发生错误:" + e.Exception.Message, e.Exception.ToString());
				OnError();
			};
			bgw.WorkCompleted += (s, e) =>
			{
				Context.IsInUpdating = false;
			};
			Context.IsInUpdating = true;
			bgw.RunWorkASync();
			CleanTemp();
		}
开发者ID:huguojunsy,项目名称:FSLib.App.SimpleUpdater,代码行数:23,代码来源:Updater.cs

示例4: BeginUpdate

 /// <summary>
 /// 开始进行更新
 /// </summary>
 internal void BeginUpdate()
 {
     var bgw = new BackgroundWorker() { WorkerSupportReportProgress = true };
     bgw.DoWork += UpdateInternal;
     bgw.WorkerProgressChanged += (s, e) => OnDownloadProgressChanged(e);
     bgw.WorkFailed += (s, e) =>
     {
         this.Exception = e.Exception;
         OnError();
     };
     bgw.RunWorkASync();
 }
开发者ID:eopeter,项目名称:dmelibrary,代码行数:15,代码来源:Updater.cs

示例5: BeginCheckUpdateInProcess

        /// <summary>
        /// 开始检测更新
        /// </summary>
        public void BeginCheckUpdateInProcess()
        {
            if (string.IsNullOrEmpty(this.UpdateUrl)) throw new InvalidOperationException(DME.Updater.SR.Updater_AssemblyNotMarkedAsUpdateable);
            if (_inRun) return;

            var bgw = new BackgroundWorker()
            {
                WorkerSupportReportProgress = true
            };
            bgw.DoWork += DownloadUpdateInfoInternal;
            bgw.WorkFailed += (s, e) =>
            {
                _inRun = false;
                this.Exception = e.Exception;
                OnError();
            };
            bgw.WorkCompleted += (s, e) =>
            {
                if (this.UpdateInfo == null) return;

                if (!string.IsNullOrEmpty(UpdateInfo.RequiredMinVersion))
                {
                    if (new Version(UpdateInfo.RequiredMinVersion) > CurrentVersion)
                    {
                        OnMinmumVersionRequired();
                        return;
                    }
                }

                var newVer = new Version(UpdateInfo.AppVersion);

                if (newVer <= CurrentVersion)
                {
                    OnNoUpdatesFound();
                }
                else OnUpdatesFound();

                _inRun = false;
            };
            bgw.WorkerProgressChanged += (s, e) =>
            {
                OnDownloadProgressChanged(e);
            };
            _inRun = true;
            bgw.RunWorkASync();
        }
开发者ID:eopeter,项目名称:dmelibrary,代码行数:49,代码来源:Updater.cs


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