Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/csharp/programming-guide/concepts/async/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Async methods are intended to be non-blocking operations. An `await` expression

The `async` and `await` keywords don't cause additional threads to be created. Async methods don't require multithreading because an async method doesn't run on its own thread. The method runs on the current synchronization context and uses time on the thread only when the method is active. You can use <xref:System.Threading.Tasks.Task.Run%2A?displayProperty=nameWithType> to move CPU-bound work to a background thread, but a background thread doesn't help with a process that's just waiting for results to become available.

The async-based approach to asynchronous programming is preferable to existing approaches in almost every case. In particular, this approach is better than the <xref:System.ComponentModel.BackgroundWorker> class for IO-bound operations because the code is simpler and you don't have to guard against race conditions. In combination with the <xref:System.Threading.Tasks.Task.Run%2A?displayProperty=nameWithType> method, async programming is better than <xref:System.ComponentModel.BackgroundWorker> for CPU-bound operations because async programming separates the coordination details of running your code from the work that `Task.Run` transfers to the threadpool.
The async-based approach to asynchronous programming is preferable to existing approaches in almost every case. In particular, this approach is better than the <xref:System.ComponentModel.BackgroundWorker> class for I/O-bound operations because the code is simpler and you don't have to guard against race conditions. In combination with the <xref:System.Threading.Tasks.Task.Run%2A?displayProperty=nameWithType> method, async programming is better than <xref:System.ComponentModel.BackgroundWorker> for CPU-bound operations because async programming separates the coordination details of running your code from the work that `Task.Run` transfers to the threadpool.

## <a name="BKMK_AsyncandAwait"></a> async and await
If you specify that a method is an async method by using the [async](../../../../csharp/language-reference/keywords/async.md) modifier, you enable the following two capabilities.
Expand Down
4 changes: 2 additions & 2 deletions docs/framework/wcf/diagnostics/etw/133-actionitemscheduled.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ ms.workload:
|Channel|Microsoft-Windows-Application Server-Applications/Debug|

## Description
This event is emitted when the IO Thread scheduler callback invoke starts.
This event is emitted when the I/O Thread scheduler callback invoke starts.

## Message
IO Thread scheduler callback invoked.
I/O Thread scheduler callback invoked.

## Details
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ ms.workload:
|Channel|Microsoft-Windows-Application Server-Applications/Debug|

## Description
This event is emitted when the IO Thread scheduler callback invoke ends.
This event is emitted when the I/O Thread scheduler callback invoke ends.

## Message
IO Thread scheduler callback invoked.
I/O Thread scheduler callback invoked.

## Details
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ms.workload:
# How to: Create a Custom Persistence Participant
The following procedure has steps to create a persistence participant. See the [Participating in Persistence](http://go.microsoft.com/fwlink/?LinkID=177735) sample and [Store Extensibility](../../../docs/framework/windows-workflow-foundation/store-extensibility.md) topic for sample implementations of persistence participants.

1. Create a class deriving from the <xref:System.Activities.Persistence.PersistenceParticipant> or the <xref:System.Activities.Persistence.PersistenceIOParticipant> class. The PersistenceIOParticipant class offers the same extensibility points as the PersistenceParticipant class in addition to being able to participate in IO operations. Follow one or more of the following steps.
1. Create a class deriving from the <xref:System.Activities.Persistence.PersistenceParticipant> or the <xref:System.Activities.Persistence.PersistenceIOParticipant> class. The PersistenceIOParticipant class offers the same extensibility points as the PersistenceParticipant class in addition to being able to participate in I/O operations. Follow one or more of the following steps.

2. Implement the <xref:System.Activities.Persistence.PersistenceParticipant.CollectValues%2A> method. The **CollectValues** method has two dictionary parameters, one for storing read/write values and the other one for storing write-only values (used later in queries). In this method, you should populate these dictionaries with data that is specific to a persistence participant. Each dictionary contains the name of the value as the key and the value itself as an <xref:System.Runtime.DurableInstancing.InstanceValue> object.

Expand All @@ -42,13 +42,13 @@ The following procedure has steps to create a persistence participant. See the [
protected virtual void PublishValues (IDictionary<XName,Object> readWriteValues)
```

5. Implement the **BeginOnSave** method if the participant is a persistence IO participant. This method is called during a Save operation. In this method, you should perform IO adjunct to the persisting (saving) workflow instances. If the host is using a transaction for the corresponding persistence command, the same transaction is provided in Transaction.Current. Additionally, PersistenceIOParticipants may advertise a transactional consistency requirement, in which case the host creates a transaction for the persistence episode if one would not otherwise be used.
5. Implement the **BeginOnSave** method if the participant is a persistence I/O participant. This method is called during a Save operation. In this method, you should perform I/O adjunct to the persisting (saving) workflow instances. If the host is using a transaction for the corresponding persistence command, the same transaction is provided in Transaction.Current. Additionally, PersistenceIOParticipants may advertise a transactional consistency requirement, in which case the host creates a transaction for the persistence episode if one would not otherwise be used.

```
protected virtual IAsyncResult BeginOnSave (IDictionary<XName,Object> readWriteValues, IDictionary<XName,Object> writeOnlyValues, TimeSpan timeout, AsyncCallback callback, Object state)
```

6. Implement the **BeginOnLoad** method if the participant is a persistence IO participant. This method is called during a Load operation. In this method, you should perform IO adjunct to the loading of workflow instances. If the host is using a transaction for the corresponding persistence command, the same transaction is provided in Transaction.Current. Additionally, Persistence IO participants may advertise a transactional consistency requirement, in which case the host creates a transaction for the persistence episode if one would not otherwise be used.
6. Implement the **BeginOnLoad** method if the participant is a persistence I/O participant. This method is called during a Load operation. In this method, you should perform I/O adjunct to the loading of workflow instances. If the host is using a transaction for the corresponding persistence command, the same transaction is provided in Transaction.Current. Additionally, Persistence I/O participants may advertise a transactional consistency requirement, in which case the host creates a transaction for the persistence episode if one would not otherwise be used.

```
protected virtual IAsyncResult BeginOnLoad (IDictionary<XName,Object> readWriteValues, TimeSpan timeout, AsyncCallback callback, Object state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ms.workload:
# Persistence Participants
A persistence participant can participate in a persistence operation (Save or Load) triggered by an application host. The [!INCLUDE[netfx_current_long](../../../includes/netfx-current-long-md.md)] ships with two abstract classes, **PersistenceParticipant** and **PersistenceIOParticipant**, which you can use to create a persistence participant. A persistence participant derives from one of these classes, implements the methods of interest, and then adds an instance of the class to the <xref:System.ServiceModel.Activities.WorkflowServiceHost.WorkflowExtensions%2A> collection on the <xref:System.ServiceModel.Activities.WorkflowServiceHost> . The application host may look for such workflow extensions when persisting a workflow instance and invoke appropriate methods on the persistence participants at appropriate times.

The following list describes the tasks performed by the persistence subsystem in different stages of the Persist (Save) operation. The persistence participants are used in the third and fourth stages. If the participant is an IO participant (a persistence participant that also participates in IO operations), the participant is also used in the sixth stage.
The following list describes the tasks performed by the persistence subsystem in different stages of the Persist (Save) operation. The persistence participants are used in the third and fourth stages. If the participant is an I/O participant (a persistence participant that also participates in I/O operations), the participant is also used in the sixth stage.

1. Gathers built-in values, including workflow state, bookmarks, mapped variables, and timestamp.

Expand All @@ -30,27 +30,27 @@ A persistence participant can participate in a persistence operation (Save or Lo

5. Persist or save the workflow into the persistence store.

6. Invokes the <xref:System.Activities.Persistence.PersistenceIOParticipant.BeginOnSave%2A> method on all of the persistence IO participants. If the participant is not an IO participant, this task is skipped. If the persistence episode is transactional, the transaction is provided in Transaction.Current property.
6. Invokes the <xref:System.Activities.Persistence.PersistenceIOParticipant.BeginOnSave%2A> method on all of the persistence I/O participants. If the participant is not an I/O participant, this task is skipped. If the persistence episode is transactional, the transaction is provided in Transaction.Current property.

7. Waits for all persistence participants to complete. If all the participants succeed in persisting instance data, commits the transaction.

A persistence participant derives from the **PersistenceParticipant** class and may implement the **CollectValues** and **MapValues** methods. A persistence IO participant derives from the **PersistenceIOParticipant** class and may implement the **BeginOnSave** method in addition to implementing the **CollectValues** and **MapValues** methods.
A persistence participant derives from the **PersistenceParticipant** class and may implement the **CollectValues** and **MapValues** methods. A persistence I/O participant derives from the **PersistenceIOParticipant** class and may implement the **BeginOnSave** method in addition to implementing the **CollectValues** and **MapValues** methods.

Each stage is completed before the next stage begins. For example, values are collected from **all** persistence participants in the first stage. Then all the values collected in the first stage are provided to all persistence participants in the second stage for mapping. Then all the values collected and mapped in the first and second stages are provided to the persistence provider in the third stage, and so on.

The following list describes the tasks performed by the persistence subsystem in different stages of the Load operation. The persistence participants are used in the fourth stage. The persistence IO participants (persistence participants that also participate in IO operations) are also used in the third stage.
The following list describes the tasks performed by the persistence subsystem in different stages of the Load operation. The persistence participants are used in the fourth stage. The persistence I/O participants (persistence participants that also participate in I/O operations) are also used in the third stage.

1. Gathers all persistence participants that were added to the extension collection associated with the workflow instance.

2. Loads the workflow from the persistence store.

3. Invokes the <xref:System.Activities.Persistence.PersistenceIOParticipant.BeginOnLoad%2A> on all persistence IO participants and waits for all the persistence participants to complete. If the persistence episode is transactional, the transaction is provided in Transaction.Current.
3. Invokes the <xref:System.Activities.Persistence.PersistenceIOParticipant.BeginOnLoad%2A> on all persistence I/O participants and waits for all the persistence participants to complete. If the persistence episode is transactional, the transaction is provided in Transaction.Current.

4. Loads the workflow instance in memory based on the data retrieved from the persistence store.

5. Invokes <xref:System.Activities.Persistence.PersistenceParticipant.PublishValues%2A> on each persistence participant.

A persistence participant derives from the **PersistenceParticipant** class and may implement the **PublishValues** method. A persistence IO participant derives from the **PersistenceIOParticipant** class and may implement the **BeginOnLoad** method in addition to implementing the **PublishValues** method.
A persistence participant derives from the **PersistenceParticipant** class and may implement the **PublishValues** method. A persistence I/O participant derives from the **PersistenceIOParticipant** class and may implement the **BeginOnLoad** method in addition to implementing the **PublishValues** method.

When loading a workflow instance the persistence provider creates a lock on that instance. This prevents the instance from being loaded by more than one host in a multi-node scenario. If you attempt to load a workflow instance that has been locked you will see an exception like the following: The exception " System.ServiceModel.Persistence.InstanceLockException: The requested operation could not complete because the lock for instance '00000000-0000-0000-0000-000000000000' could not be acquired". This error is caused when one of the following occurs:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This topic describes best practices for security in applications when you use XA
## Untrusted XAML in Applications
In the most general sense, untrusted XAML is any XAML source that your application did not specifically include or emit.

XAML that is compiled into or stored as a `resx`-type resource within a trusted and signed assembly is not inherently untrusted. You can trust the XAML as much as you trust the assembly as a whole. In most cases, you are only concerned with the trust aspects of loose XAML, which is a XAML source that you load from a stream or other IO. Loose XAML is not a specific component or feature of an application model with a deployment and packaging infrastructure. However, an assembly might implement a behavior that involves loading loose XAML.
XAML that is compiled into or stored as a `resx`-type resource within a trusted and signed assembly is not inherently untrusted. You can trust the XAML as much as you trust the assembly as a whole. In most cases, you are only concerned with the trust aspects of loose XAML, which is a XAML source that you load from a stream or other I/O. Loose XAML is not a specific component or feature of an application model with a deployment and packaging infrastructure. However, an assembly might implement a behavior that involves loading loose XAML.

For untrusted XAML, you should treat it generally the same as if it were untrusted code. Use sandboxing or other metaphors to prevent possibly untrusted XAML from accessing your trusted code.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ You may implement the TAP pattern manually for better control over implementatio
Another case where such delegation is useful is when you're implementing fast-path optimization and want to return a cached task.

## Workloads
You may implement both compute-bound and I/O-bound asynchronous operations as TAP methods. However, when TAP methods are exposed publicly from a library, they should be provided only for workloads that involve I/O-bound operations (they may also involve computation, but should not be purely computational). If a method is purely compute-bound, it should be exposed only as a synchronous implementation. The code that consumes it may then choose whether to wrap an invocation of that synchronous method into a task to offload the work to another thread or to achieve parallelism. And if a method is IO-bound, it should be exposed only as an asynchronous implementation.
You may implement both compute-bound and I/O-bound asynchronous operations as TAP methods. However, when TAP methods are exposed publicly from a library, they should be provided only for workloads that involve I/O-bound operations (they may also involve computation, but should not be purely computational). If a method is purely compute-bound, it should be exposed only as a synchronous implementation. The code that consumes it may then choose whether to wrap an invocation of that synchronous method into a task to offload the work to another thread or to achieve parallelism. And if a method is I/O-bound, it should be exposed only as an asynchronous implementation.

### Compute-bound tasks
The <xref:System.Threading.Tasks.Task?displayProperty=nameWithType> class is ideally suited for representing computationally intensive operations. By default, it takes advantage of special support within the <xref:System.Threading.ThreadPool> class to provide efficient execution, and it also provides significant control over when, where, and how asynchronous computations execute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Dim urlContents As String = Await client.GetStringAsync()

The `Async` and `Await` keywords don't cause additional threads to be created. Async methods don't require multithreading because an async method doesn't run on its own thread. The method runs on the current synchronization context and uses time on the thread only when the method is active. You can use <xref:System.Threading.Tasks.Task.Run%2A?displayProperty=nameWithType> to move CPU-bound work to a background thread, but a background thread doesn't help with a process that's just waiting for results to become available.

The async-based approach to asynchronous programming is preferable to existing approaches in almost every case. In particular, this approach is better than <xref:System.ComponentModel.BackgroundWorker> for IO-bound operations because the code is simpler and you don't have to guard against race conditions. In combination with <xref:System.Threading.Tasks.Task.Run%2A?displayProperty=nameWithType>, async programming is better than <xref:System.ComponentModel.BackgroundWorker> for CPU-bound operations because async programming separates the coordination details of running your code from the work that `Task.Run` transfers to the threadpool.
The async-based approach to asynchronous programming is preferable to existing approaches in almost every case. In particular, this approach is better than <xref:System.ComponentModel.BackgroundWorker> for I/O-bound operations because the code is simpler and you don't have to guard against race conditions. In combination with <xref:System.Threading.Tasks.Task.Run%2A?displayProperty=nameWithType>, async programming is better than <xref:System.ComponentModel.BackgroundWorker> for CPU-bound operations because async programming separates the coordination details of running your code from the work that `Task.Run` transfers to the threadpool.

## <a name="BKMK_AsyncandAwait"></a> Async and Await
If you specify that a method is an async method by using an [Async](../../../../visual-basic/language-reference/modifiers/async.md) modifier, you enable the following two capabilities.
Expand Down