Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This article provides a sample of how to use methods in workflows. It also demonstrates a thread for methods that do not have to wait to run.

Script

Code Block
languagec#
public bool Run(ScriptContext context)
{
    string p1 = "test1";
    long p2 = 4715821396025;
    int p3 = 4096;
    object args = new object[3] { p1, p2, p3 };
    System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(test));
    thread.Start(args);
    return true;
}

public void test(object args)
{
    Array argArray = new object[3];
    argArray = (Array)args;
    string p1 = (string)argArray.GetValue(0);
    long p2 = (long)argArray.GetValue(1);
    int p3 = (int)argArray.GetValue(2);
    Console.WriteLine("Hello");
    System.Threading.Thread.Sleep(2000);
    Console.WriteLine("Done");
}

...