/// <summary> /// Executes the Activity /// </summary> /// <param name="context"></param> protected override void Execute(NativeActivityContext context) { // // We must enter a NoPersist zone because it looks like we're idle while our // Task is executing but, we aren't really // NoPersistHandle noPersistHandle = NoPersistHandle.Get(context); noPersistHandle.Enter(context); // // Set a bookmark that we will resume when our Task is done // m_Bookmark = context.CreateBookmark(BookmarkResumptionCallback); this.Bookmark.Set(context, m_Bookmark); m_BookmarkResumptionHelper = context.GetExtension <BookmarkResumptionHelper>(); // // Prepare to execute // PrepareToExecute(context); // // Start a Task to do the actual execution of our activity // CancellationTokenSource tokenSource = new CancellationTokenSource(); m_Task = Task.Factory.StartNew(ExecuteNonblocking, tokenSource.Token); m_Task.ContinueWith(TaskCompletionCallback); }
protected override void Execute(NativeActivityContext context) { this.RuntimeBookmark = (context.Properties.Find("MonitorBookmark") as Bookmark); if (this.RuntimeBookmark == null) { return; } this.BookmarkResumptionHelper = context.GetExtension <BookmarkResumptionHelper>(); this.StartMonitor(context); context.CreateBookmark(); }
protected override void Execute(NativeActivityContext context) { try { this.EventQueue.Clear(); this._monitorBookmark = context.CreateBookmark(new BookmarkCallback(this.OnMonitorTrigger), BookmarkOptions.MultipleResume); this._bookmarkResumptionHelper = context.GetExtension <BookmarkResumptionHelper>(); context.Properties.Add("MonitorBookmark", this._monitorBookmark, true); this.StartMonitor(context); } catch (Exception ex) { this.DisposeMonitor(context); this.HandleException(ex, this.ContinueOnError.Get(context)); } }