Difference between CodeActivity, NativeActivity and AsyncCodeActivity while creating a Custom Activity

Difference between CodeActivity, NativeActivity and AsyncCodeActivity while creating a Custom Activity

There are some built in common activities comes with .Net framework. But, workflow is basically to support your business process. Since Microsoft cannot provide all activites which are required for your business, you may need to create your own custom and reusable activities.Those custom activities can be created by deriving from “CodeActivity” or “NativeActivity”.

CodeActivity is a very simple activity. You may create Custom code activity, when want to do some action and complete the activity. Code activity will just provide override for the method “execute”. This method will be called whenever your custom activity is executed.
public abstract class CodeActivity : System.Activities.Activity

public sealed class MessageBox : CodeActivity
{
 
public InArgument<string> Text{ get; set; }
protected override void Execute(CodeActivityContext context) {
  System.Windows.Forms.MessageBox.Show(
this.Text.Get(context));
  }
}

For more detail click here

NativeActivity provides more functionality and allows creating complex activities. Native Activity can schedule one or more different activities for execution which is not possible in Code Activity. Another important feature is, if you want to implement workflow persistence service by creating “Bookmark”, then you can do it only if your custom activity is derived from Native Activity. Apart from this, Native activity has access to all the features exposed by the workflow which includes Tracking.
public abstract class NativeActivity : System.Activities.Activity
For more details refer to https://docs.microsoft.com/en-us/dotnet/api/system.activities.nativeactivity?view=netframework-4.8

AsyncCodeActivity manages asynchronous code activity execution from start to completion. This is an abstract class.
public<span style="color: rgb(23, 23, 23);font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier,