WorkflowApplication.GetBookmarks Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Devolve a coleção de favoritos para a instância do workflow.
Sobrecargas
| Name | Description |
|---|---|
| GetBookmarks() |
Devolve a coleção de favoritos para a instância do workflow. |
| GetBookmarks(TimeSpan) |
Devolve a coleção de favoritos para a instância do fluxo de trabalho usando o intervalo de tempo especificado. |
GetBookmarks()
Devolve a coleção de favoritos para a instância do workflow.
public:
System::Collections::ObjectModel::ReadOnlyCollection<System::Activities::Hosting::BookmarkInfo ^> ^ GetBookmarks();
public System.Collections.ObjectModel.ReadOnlyCollection<System.Activities.Hosting.BookmarkInfo> GetBookmarks();
member this.GetBookmarks : unit -> System.Collections.ObjectModel.ReadOnlyCollection<System.Activities.Hosting.BookmarkInfo>
Public Function GetBookmarks () As ReadOnlyCollection(Of BookmarkInfo)
Devoluções
Uma coleção de marcadores de livros apenas de leitura para a instância do workflow.
Exemplos
O exemplo seguinte cria um fluxo de trabalho que utiliza uma ReadLine atividade que cria um Bookmark. O fluxo de trabalho é iniciado e, uma vez que o Bookmark é criado e o fluxo de trabalho entra em estado de espera, GetBookmarks é chamado. Quando o fluxo de trabalho é concluído, a saída a seguir é exibida no console.
What is your name?
BookmarkName: UserName - OwnerDisplayName: ReadLine
Steve
Hello, Steve
public sealed class ReadLine : NativeActivity<string>
{
[RequiredArgument]
public InArgument<string> BookmarkName { get; set; }
protected override void Execute(NativeActivityContext context)
{
// Create a Bookmark and wait for it to be resumed.
context.CreateBookmark(BookmarkName.Get(context),
new BookmarkCallback(OnResumeBookmark));
}
// NativeActivity derived activities that do asynchronous operations by calling
// one of the CreateBookmark overloads defined on System.Activities.NativeActivityContext
// must override the CanInduceIdle property and return true.
protected override bool CanInduceIdle
{
get { return true; }
}
public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
{
// When the Bookmark is resumed, assign its value to
// the Result argument.
Result.Set(context, (string)obj);
}
Variable<string> name = new Variable<string>();
Activity wf = new Sequence
{
Variables = { name },
Activities =
{
new WriteLine
{
Text = "What is your name?"
},
new ReadLine
{
BookmarkName = "UserName",
Result = new OutArgument<string>(name)
},
new WriteLine
{
Text = new InArgument<string>((env) =>
("Hello, " + name.Get(env)))
}
}
};
// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);
// Workflow lifecycle events omitted except idle.
AutoResetEvent idleEvent = new AutoResetEvent(false);
wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
// You can also inspect the bookmarks from the Idle handler
// using e.Bookmarks
idleEvent.Set();
};
// Run the workflow.
wfApp.Run();
// Wait for the workflow to go idle and give it a chance
// to create the Bookmark.
idleEvent.WaitOne();
// Inspect the bookmarks
foreach (BookmarkInfo info in wfApp.GetBookmarks())
{
Console.WriteLine("BookmarkName: {0} - OwnerDisplayName: {1}",
info.BookmarkName, info.OwnerDisplayName);
}
// Gather the user's input and resume the bookmark.
wfApp.ResumeBookmark("UserName", Console.ReadLine());
Observações
Se esta operação não for concluída em 30 segundos, é lançado um TimeoutException a.
Aplica-se a
GetBookmarks(TimeSpan)
Devolve a coleção de favoritos para a instância do fluxo de trabalho usando o intervalo de tempo especificado.
public:
System::Collections::ObjectModel::ReadOnlyCollection<System::Activities::Hosting::BookmarkInfo ^> ^ GetBookmarks(TimeSpan timeout);
public System.Collections.ObjectModel.ReadOnlyCollection<System.Activities.Hosting.BookmarkInfo> GetBookmarks(TimeSpan timeout);
member this.GetBookmarks : TimeSpan -> System.Collections.ObjectModel.ReadOnlyCollection<System.Activities.Hosting.BookmarkInfo>
Public Function GetBookmarks (timeout As TimeSpan) As ReadOnlyCollection(Of BookmarkInfo)
Parâmetros
- timeout
- TimeSpan
O intervalo em que este método deve ser concluído antes de a operação ser cancelada e a TimeoutException ser lançado.
Devoluções
Uma coleção de marcadores de livros apenas de leitura para a instância do workflow.
Exemplos
O exemplo seguinte cria um fluxo de trabalho que utiliza uma ReadLine atividade que cria um Bookmark. O fluxo de trabalho é iniciado e, uma vez que o Bookmark é criado e o fluxo de trabalho entra em estado de espera, GetBookmarks é chamado. Quando o fluxo de trabalho é concluído, a saída a seguir é exibida no console.
What is your name?
BookmarkName: UserName - OwnerDisplayName: ReadLine
Steve
Hello, Steve
public sealed class ReadLine : NativeActivity<string>
{
[RequiredArgument]
public InArgument<string> BookmarkName { get; set; }
protected override void Execute(NativeActivityContext context)
{
// Create a Bookmark and wait for it to be resumed.
context.CreateBookmark(BookmarkName.Get(context),
new BookmarkCallback(OnResumeBookmark));
}
// NativeActivity derived activities that do asynchronous operations by calling
// one of the CreateBookmark overloads defined on System.Activities.NativeActivityContext
// must override the CanInduceIdle property and return true.
protected override bool CanInduceIdle
{
get { return true; }
}
public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
{
// When the Bookmark is resumed, assign its value to
// the Result argument.
Result.Set(context, (string)obj);
}
Variable<string> name = new Variable<string>();
Activity wf = new Sequence
{
Variables = { name },
Activities =
{
new WriteLine
{
Text = "What is your name?"
},
new ReadLine
{
BookmarkName = "UserName",
Result = new OutArgument<string>(name)
},
new WriteLine
{
Text = new InArgument<string>((env) =>
("Hello, " + name.Get(env)))
}
}
};
// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);
// Workflow lifecycle events omitted except idle.
AutoResetEvent idleEvent = new AutoResetEvent(false);
wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
// You can also inspect the bookmarks from the Idle handler
// using e.Bookmarks
idleEvent.Set();
};
// Run the workflow.
wfApp.Run();
// Wait for the workflow to go idle and give it a chance
// to create the Bookmark.
idleEvent.WaitOne();
// Inspect the bookmarks
foreach (BookmarkInfo info in wfApp.GetBookmarks())
{
Console.WriteLine("BookmarkName: {0} - OwnerDisplayName: {1}",
info.BookmarkName, info.OwnerDisplayName);
}
// Gather the user's input and resume the bookmark.
wfApp.ResumeBookmark("UserName", Console.ReadLine());