Repository navigation
Expand file tree
/
Copy pathBookmark.xml
More file actions
282 lines (261 loc) · 13.7 KB
/
Copy pathBookmark.xml
File metadata and controls
282 lines (261 loc) · 13.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<Type Name="Bookmark" FullName="System.Activities.Bookmark">
<TypeSignature Language="C#" Value="public class Bookmark : IEquatable<System.Activities.Bookmark>" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit Bookmark extends System.Object implements class System.IEquatable`1<class System.Activities.Bookmark>" />
<TypeSignature Language="DocId" Value="T:System.Activities.Bookmark" />
<TypeSignature Language="VB.NET" Value="Public Class Bookmark
Implements IEquatable(Of Bookmark)" />
<TypeSignature Language="C++ CLI" Value="public ref class Bookmark : IEquatable<System::Activities::Bookmark ^>" />
<AssemblyInfo>
<AssemblyName>System.Activities</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.IEquatable<System.Activities.Bookmark></InterfaceName>
</Interface>
</Interfaces>
<Attributes>
<Attribute>
<AttributeName>System.Runtime.Serialization.DataContract</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents a point at which a workflow or activity can passively wait to be resumed.</summary>
<remarks>
<format type="text/markdown"><, [Bookmarks](~/docs/framework/windows-workflow-foundation/bookmarks.md), and the [Bookmarks [ WF Samples]](~/docs/framework/windows-workflow-foundation/samples/bookmarks.md) and [Wait For Input Activity [WF Samples]](~/docs/framework/windows-workflow-foundation/samples/wait-for-input-activity.md) samples.
## Examples
In the following example, a `ReadLine` activity is created. When executed, the `ReadLine` activity creates a <xref:System.Activities.Bookmark>, registers a callback, and then waits for the <xref:System.Activities.Bookmark> to be resumed. When it is resumed, the `ReadLine` activity assigns the data that was passed with the <xref:System.Activities.Bookmark> to its <xref:System.Activities.Activity%601.Result%2A> argument.
```csharp
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);
}
}
```
In the following example, a workflow is created that uses the `ReadLine` activity to gather the user’s name and display it to the console window. The host application performs the actual work of gathering the input and passes it to the workflow by resuming the <xref:System.Activities.Bookmark>.
```csharp
Variable<string> name = new Variable<string>
{
Name = "name"
};
Activity wf = new Sequence
{
Variables =
{
name
},
Activities =
{
new WriteLine()
{
Text = "What is your name?"
},
new ReadLine()
{
BookmarkName = "UserName",
Result = name
},
new WriteLine()
{
Text = new InArgument<string>((env) => "Hello, " + name.Get(env))
}
}
};
AutoResetEvent syncEvent = new AutoResetEvent(false);
// Create the WorkflowApplication using the desired
// workflow definition.
WorkflowApplication wfApp = new WorkflowApplication(wf);
// Handle the desired lifecycle events.
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
// Signal the host that the workflow is complete.
syncEvent.Set();
};
// Start the workflow.
wfApp.Run();
// Collect the user's name and resume the bookmark.
// Bookmark resumption only occurs when the workflow
// is idle. If a call to ResumeBookmark is made and the workflow
// is not idle, ResumeBookmark blocks until the workflow becomes
// idle before resuming the bookmark.
wfApp.ResumeBookmark("UserName", Console.ReadLine());
// Wait for Completed to arrive and signal that
// the workflow is complete.
syncEvent.WaitOne();
```
When the `ReadLine` activity is executed, it creates a <xref:System.Activities.Bookmark> named `UserName` and then waits for the bookmark to be resumed. The host collects the desired data and then resumes the <xref:System.Activities.Bookmark>. The workflow resumes, displays the name, and then completes. Note that no synchronization code is required with regard to resuming the bookmark. A <xref:System.Activities.Bookmark> can only be resumed when the workflow is idle, and if the workflow is not idle, the call to <xref:System.Activities.WorkflowApplication.ResumeBookmark%2A> blocks until the workflow becomes idle.
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public Bookmark (string name);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string name) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Activities.Bookmark.#ctor(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (name As String)" />
<MemberSignature Language="C++ CLI" Value="public:
 Bookmark(System::String ^ name);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Activities</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="name" Type="System.String" />
</Parameters>
<Docs>
<param name="name">A name that identifies the bookmark.</param>
<summary>Initializes a new instance of the <see cref="T:System.Activities.Bookmark" /> class using the specified name.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<MemberGroup MemberName="Equals">
<AssemblyInfo>
<AssemblyName>System.Activities</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Determines whether two <see cref="T:System.Activities.Bookmark" /> objects refer to the same continuation point in a workflow.</summary>
</Docs>
</MemberGroup>
<Member MemberName="Equals">
<MemberSignature Language="C#" Value="public bool Equals (System.Activities.Bookmark other);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool Equals(class System.Activities.Bookmark other) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Activities.Bookmark.Equals(System.Activities.Bookmark)" />
<MemberSignature Language="VB.NET" Value="Public Function Equals (other As Bookmark) As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual bool Equals(System::Activities::Bookmark ^ other);" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.IEquatable`1.Equals(`0)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Activities</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="other" Type="System.Activities.Bookmark" />
</Parameters>
<Docs>
<param name="other">The bookmark to compare.</param>
<summary>Determines whether the current <see cref="T:System.Activities.Bookmark" /> and the specified <see cref="T:System.Activities.Bookmark" /> refer to the same continuation point in a workflow.</summary>
<returns>
<see langword="true" /> if the <see cref="T:System.Activities.Bookmark" /> objects are equal; otherwise, <see langword="false" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Equals">
<MemberSignature Language="C#" Value="public override bool Equals (object obj);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance bool Equals(object obj) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Activities.Bookmark.Equals(System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function Equals (obj As Object) As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:
 override bool Equals(System::Object ^ obj);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Activities</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="obj" Type="System.Object" />
</Parameters>
<Docs>
<param name="obj">The object to compare.</param>
<summary>Determines whether the current <see cref="T:System.Activities.Bookmark" /> and the specified object refer to the same continuation point in a workflow.</summary>
<returns>
<see langword="true" /> if the <see cref="T:System.Activities.Bookmark" /> objects are equal; otherwise, <see langword="false" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="GetHashCode">
<MemberSignature Language="C#" Value="public override int GetHashCode ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetHashCode() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Activities.Bookmark.GetHashCode" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetHashCode () As Integer" />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetHashCode();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Activities</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Returns a unique identifier for this <see cref="T:System.Activities.Bookmark" /> instance.</summary>
<returns>The unique identifier of this <see cref="T:System.Activities.Bookmark" /> instance.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Name">
<MemberSignature Language="C#" Value="public string Name { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Name" />
<MemberSignature Language="DocId" Value="P:System.Activities.Bookmark.Name" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Name As String" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ Name { System::String ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Activities</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the bookmark name.</summary>
<value>The bookmark name.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="ToString">
<MemberSignature Language="C#" Value="public override string ToString ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance string ToString() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Activities.Bookmark.ToString" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function ToString () As String" />
<MemberSignature Language="C++ CLI" Value="public:
 override System::String ^ ToString();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Activities</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Returns the bookmark name for a named bookmark or the bookmark ID for an unnamed bookmark.</summary>
<returns>The bookmark name or ID.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>