protected override void OnEnded(TaskDelegateMetadata meta, TaskEndedEventArgs ended)
 {
     if (meta.Ended != null)
     {
         Dispatcher.Invoke(new Action(() => meta.Ended(ended)));
     }
 }
示例#2
0
        private void OnTaskEnded(object sender, TaskEndedEventArgs args)
        {
            var modInfo = _apiService.GetModInfo(args.Task.ModID);

            RecordEvent(new HistoryEntry(
                            DateTime.Now,
                            args.Task.Type,
                            args.Success,
                            args.Task.ModID,
                            modInfo?.Name));
        }
 /// <summary>
 /// Handles the <see cref="IBackgroundTask.TaskEnded"/> event of the game discoverer.
 /// </summary>
 /// <remarks>
 /// If the game being searched for has not been found, this displays the not found UI.
 /// </remarks>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="e">A <see cref="TaskEndedEventArgs"/> describing the event arguments.</param>
 private void Detector_TaskEnded(object sender, TaskEndedEventArgs e)
 {
     if (InvokeRequired)
     {
         Invoke((Action <object, TaskEndedEventArgs>)Detector_TaskEnded, sender, e);
         return;
     }
     if (!Discoverer.IsFound(GameMode.ModeId) && !Discoverer.HasCandidates(GameMode.ModeId))
     {
         SetVisiblePanel(pnlNotFound);
     }
 }
示例#4
0
 /// <summary>
 /// Raises the <see cref="IBackgroundTask.TaskEnded"/> event.
 /// </summary>
 /// <remarks>
 /// This raises the <see cref="GameResolved"/> event for any games that were not found.
 /// </remarks>
 /// <param name="e">The <see cref="TaskEndedEventArgs"/> describing the event arguments.</param>
 protected override void OnTaskEnded(TaskEndedEventArgs e)
 {
     base.OnTaskEnded(e);
     string[] strModeIds = new string[m_dicCandidatePathsByGame.Count];
     m_dicCandidatePathsByGame.Keys.CopyTo(strModeIds, 0);
     foreach (string strModeId in strModeIds)
     {
         if (m_dicCandidatePathsByGame[strModeId].Count == 0)
         {
             OnGameResolved(m_dicGameModesById[strModeId], null);
         }
     }
 }
示例#5
0
        private void OnTaskEnded(object sender, TaskEndedEventArgs args)
        {
            var modInfo = _apiService.GetModInfo(args.Task.Identifier);

            RecordEvent(new HistoryEntry(
                            DateTime.Now,
                            args.Task.TaskType,
                            args.Success,
                            args.Task.FileId,
                            modInfo?.Name,
                            modInfo?.PageUrl
                            ));
        }
示例#6
0
 /// <summary>
 /// Handles the <see cref="IBackgroundTask.TaskEnded"/> event of a task set.
 /// </summary>
 /// <remarks>
 /// This displays the confirmation message.
 /// </remarks>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="e">A <see cref="TaskSetCompletedEventArgs"/> describing the event arguments.</param>
 private void ExternalTask_TaskEnded(object sender, TaskEndedEventArgs e)
 {
     if (ExternalTask != null)
     {
         lock (m_objLock)
         {
             if (ExternalTask != null)
             {
                 ExternalTask.TaskEnded -= ExternalTask_TaskEnded;
                 ExternalTask            = null;
             }
         }
     }
 }
        /// <summary>
        /// Raises the <see cref="IBackgroundTask.TaskEnded"/> event.
        /// </summary>
        /// <remarks>
        /// This raises the <see cref="GameResolved"/> event for any games that were not found.
        /// </remarks>
        /// <param name="e">The <see cref="TaskEndedEventArgs"/> describing the event arguments.</param>
        protected override void OnTaskEnded(TaskEndedEventArgs e)
        {
            base.OnTaskEnded(e);

            var modeIds = new string[_candidatePathsByGame.Count];

            _candidatePathsByGame.Keys.CopyTo(modeIds, 0);

            foreach (var modeId in modeIds)
            {
                if (_candidatePathsByGame[modeId].Count == 0)
                {
                    OnGameResolved(_gameModesById[modeId], null);
                }
            }
        }
示例#8
0
 /// <summary>
 /// Handles the <see cref="IBackgroundTask.TaskEnded"/> event of a task set.
 /// </summary>
 /// <remarks>
 /// This displays the confirmation message.
 /// </remarks>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="e">A <see cref="TaskSetCompletedEventArgs"/> describing the event arguments.</param>
 private void RunningTask_TaskEnded(object sender, TaskEndedEventArgs e)
 {
     if (RunningTask != null)
     {
         lock (m_objLock)
         {
             if (RunningTask != null)
             {
                 RunningTask.TaskEnded -= RunningTask_TaskEnded;
                 int intPosition = TaskList.IndexOf((WriteLoadOrderTask)RunningTask);
                 RunningTask = null;
                 TaskList.RemoveAt(intPosition);
             }
         }
     }
 }
示例#9
0
        private void OnTaskCompletedOrCancelled(TaskEndedEventArgs args)
        {
            string userName    = args.UserID; // ArcGIS Online signed in userName.  If not signed in to ArcGIS Online then returns the name of the user logged in to the Windows OS.
            string projectName = args.ProjectName;

            Guid   taskItemGuid    = args.TaskItemGuid;
            string taskItemName    = args.TaskItemName;
            string taskItemVersion = args.TaskItemVersion;

            Guid   taskGuid = args.TaskGuid;
            string taskName = args.TaskName;

            DateTime startTime = args.StartTime;
            DateTime endTime   = args.EndTime;
            double   duration  = args.Duration;

            bool completed = args.Completed; // completed or cancelled
        }
 /// <summary>
 /// Handles the <see cref="IBackgroundTask.TaskEnded"/> event of the mod adding task.
 /// </summary>
 /// <remarks>
 /// This retrieves the paths of the added mods.
 /// </remarks>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="e">A <see cref="TaskEndedEventArgs"/> describing the event arguments.</param>
 private void ModAdder_TaskEnded(object sender, TaskEndedEventArgs e)
 {
     if ((e.Status != TaskStatus.Paused) && (e.Status != TaskStatus.Queued))
     {
         lock (m_dicActiveTasks)
         {
             Uri uriKey = (from k in m_dicActiveTasks
                           where (k.Value == sender)
                           select k.Key).FirstOrDefault();
             if (uriKey != null)
             {
                 m_dicActiveTasks.Remove(uriKey);
             }
             if (m_dicActiveTasks.Count > 0)
             {
                 ResumeQueued();
             }
         }
     }
 }
示例#11
0
 /// <summary>
 /// Raises the <see cref="IBackgroundTask.TaskEnded"/> event.
 /// </summary>
 /// <param name="e">A <see cref="TaskEndedEventArgs"/> describing the event arguments.</param>
 protected override void OnTaskEnded(TaskEndedEventArgs e)
 {
     if (m_lstFailedUpdaters.Count > 0)
     {
         StringBuilder stbMessage = new StringBuilder();
         stbMessage.AppendLine("The following updates failed:");
         for (Int32 i = 0; i < m_lstFailedUpdaters.Count; i++)
         {
             IUpdater updUpdater = m_lstFailedUpdaters[i];
             stbMessage.AppendFormat("{0}: {1}", updUpdater.Name, updUpdater.Message);
             if (i < m_lstFailedUpdaters.Count - 1)
             {
                 stbMessage.AppendLine();
             }
         }
         base.OnTaskEnded(new TaskEndedEventArgs(e.Status, stbMessage.ToString(), e.ReturnValue));
     }
     else
     {
         base.OnTaskEnded(e);
     }
 }
 /// <summary>
 /// Raises the <see cref="IBackgroundTask.TaskEnded"/> event.
 /// </summary>
 /// <param name="e">A <see cref="TaskEndedEventArgs"/> describing the event arguments.</param>
 protected override void OnTaskEnded(TaskEndedEventArgs e)
 {
     base.OnTaskEnded(e);
 }
        /// <summary>
        /// Handles the <see cref="IBackgroundTask.TaskEnded"/> event of the task.
        /// </summary>
        /// <remarks>
        /// This sets the <see cref="Form.DialogResult"/>, dependant upon whether or not the
        /// task was cancelled.
        /// </remarks>
        /// <param name="sender">The object that triggered the event.</param>
        /// <param name="e">A <see cref="TaskEndedEventArgs"/> that describes the event arguments.</param>
        private void Task_TaskEnded(object sender, TaskEndedEventArgs e)
        {
            m_tmrGlow.Stop();
            if (Disposing || IsDisposed)
            {
                return;
            }
            try
            {
                //if the form hasn't been created, there is no point in updating
                // the UI
                //further, if the form handle hasn't been created, there is no way
                // to safely update the form from another thread
                if (IsHandleCreated)
                {
                    if (InvokeRequired)
                    {
                        Invoke((Action <object, TaskEndedEventArgs>)Task_TaskEnded, sender, e);
                        return;
                    }
                    else if ((Owner != null) && Owner.InvokeRequired)
                    {
                        Owner.Invoke((Action <object, TaskEndedEventArgs>)Task_TaskEnded, sender, e);
                        return;
                    }
                }
            }
            catch (ObjectDisposedException)
            {
                //if the control is disposed, we don't need to do anything
                return;
            }

            if (e.Status == TaskStatus.Complete)
            {
                DialogResult = DialogResult.OK;
            }
            else
            {
                DialogResult = DialogResult.Cancel;
            }
            m_drtLastDialogResult = DialogResult;
            if (e.ReturnValue != null)
            {
                ShowMessage((ViewMessage)e.ReturnValue);
            }
            else if (!String.IsNullOrEmpty(e.Message))
            {
                MessageBox.Show(this, e.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            //only try to close the form if it has been created
            // otherwise Close() can get called before the form is shown,
            // and then once Show() or ShowDialog() is called an
            // System.ObjectDisposedException is thrown
            if (IsHandleCreated)
            {
                for (Int32 i = 0; i < 10; i++)
                {
                    try
                    {
                        this.Close();
                        break;
                    }
                    catch (InvalidOperationException)
                    {
                        //we are trying to close the form at the exact moment it is being shown
                        // wait a moment and try again
                        Thread.Sleep(100);
                    }
                }
            }
        }
 /// <summary>
 /// Raises the <see cref="IBackgroundTask.TaskEnded"/> event.
 /// </summary>
 /// <remarks>
 /// This signals the <see cref="StartWait(bool, object[])"/> method that the task has ended,
 /// and makes the return value accessible to said method.
 /// </remarks>
 /// <param name="e">A <see cref="TaskEndedEventArgs"/> describing the event arguments.</param>
 protected override void OnTaskEnded(TaskEndedEventArgs e)
 {
     m_areTaskEnded.Set();
     m_objReturnValue = e.ReturnValue;
     base.OnTaskEnded(e);
 }
示例#15
0
		/// <summary>
		/// Handles the <see cref="IBackgroundTask.TaskEnded"/> event of the task.
		/// </summary>
		/// <remarks>
		/// This sets the <see cref="Form.DialogResult"/>, dependant upon whether or not the
		/// task was cancelled.
		/// </remarks>
		/// <param name="sender">The object that triggered the event.</param>
		/// <param name="e">A <see cref="TaskEndedEventArgs"/> that describes the event arguments.</param>
		private void Task_TaskEnded(object sender, TaskEndedEventArgs e)
		{
			if (Disposing || IsDisposed)
				return;
			try
			{
				//if the form hasn't been created, there is no point in updating
				// the UI
				//further, if the form handle hasn't been created, there is no way
				// to safely update the form from another thread
				if (IsHandleCreated)
				{

					if (InvokeRequired)
					{
						Invoke((Action<object, TaskEndedEventArgs>)Task_TaskEnded, sender, e);
						return;
					}
					else if ((Owner != null) && Owner.InvokeRequired)
					{
						Owner.Invoke((Action<object, TaskEndedEventArgs>)Task_TaskEnded, sender, e);
						return;
					}
				}
			}
			catch (ObjectDisposedException)
			{
				//if the control is disposed, we don't need to do anything
				return;
			}

			if (e.Status == TaskStatus.Complete)
				DialogResult = DialogResult.OK;
			else
				DialogResult = DialogResult.Cancel;
			m_drtLastDialogResult = DialogResult;
			if (!String.IsNullOrEmpty(e.Message))
				MessageBox.Show(this, e.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
			//only try to close the form if it has been created
			// otherwise Close() can get called before the form is shown,
			// and then once Show() or ShowDialog() is called an
			// System.ObjectDisposedException is thrown
			if (IsHandleCreated)
			{
				for (Int32 i = 0; i < 10; i++)
				{
					try
					{
						this.Close();
						break;
					}
					catch (InvalidOperationException)
					{
						//we are trying to close the form at the exact moment it is being shown
						// wait a moment and try again
						Thread.Sleep(100);
					}
				}
			}
		}
示例#16
0
 /// <summary>
 /// Raises the <see cref="TaskEnded"/> event.
 /// </summary>
 /// <param name="e">A <see cref="TaskEndedEventArgs"/> describing the event arguments.</param>
 protected virtual void OnTaskEnded(TaskEndedEventArgs e)
 {
     ReturnValue = e.ReturnValue;
     TaskEnded(this, e);
 }
示例#17
0
 protected override void OnEnded(TaskEndedEventArgs e)
 {
     pg.RaiseInitializeEnd();
     pg.EndInit();
 }