/// <summary>
        /// When implemented in a derived class, runs the activity’s execution logic.
        /// </summary>
        /// <param name="context">The execution context in which the activity executes.</param>
        protected override void Execute(System.Activities.NativeActivityContext context)
        {
            // Enter a no persist zone to pin this activity to memory since we are setting up a delegate to receive a callback
            var handle = this.noPersistHandle.Get(context);

            handle.Enter(context);

            // Get (which may create) the extension
            var extension = context.GetExtension <Hosting.FolderWatcherExtension>();

            string folder = context.GetValue(this.WatchFolder);

            if (!System.IO.Directory.Exists(folder))
            {
                throw new OperationCanceledException(String.Format("The path \"{0}\" is not a directory or does not exist.", folder));
            }

            // Set a bookmark - the extension will resume when the FileSystemWatcher is fired
            var bookmark = context.CreateBookmark(String.Format("FolderWatch_{0:N}", Guid.NewGuid()), FileWatcherBookmarkCallback);

            bookmarkWatcher.Set(context, bookmark);

            extension.RegisterListener(bookmark, folder, context.GetValue(this.WatchPattern), this.WatchSubfolders);
        }
Exemplo n.º 2
0
        protected override void Execute(NativeActivityContext context)
        {
            string bookmarkName = this.operationName;// OperationName.Get(context);

            context.CreateBookmark(bookmarkName, new BookmarkCallback(BookmarkCallback), BookmarkOptions.MultipleResume);
        }