K2 has server events for implementing system tasks. By default when you drag and drop a server event template the code you write there runs top to bottom and the event completes.
If you look at the server event’s properties there is a boolean property named Synchronous. By default this is set to true. If you set this value to false, you get a different mechanism for interacting with K2. This is called the K2 asynchronous event.
The asynchronous server event is akin to a task but there is no “user” assigned to this task. An asynchronous server events makes K2 to execute what ever code you wrote in the event template, top to bottom and then wait for a callback to complete that event.
K2 server provides a correlation ID to call back in to K2 to finish this server event. this mechanism is very useful for long running external processing to take place while workflow can do other things.
Typically the external call back will connect to K2 and present this correlation ID called a server item serial number then do something with the process instance and call the finish method on the server event. then K2 continues with the next event, line rule or activity in the process instance.
using (Connection con = new Connection())
ServerItem si = con.openServerItem(serialnumber);
si.ProcessInstance.DataFields["name"].value = "call back value";
There is also a process level permission called the “server event” which has to be set for the user who opens the connection to complete this server event. so, if you are expecting your biztalk service account to do this call back, that account must have server event permission assigned on this process.
Here’s a KB article on this topic http://kb.k2workflow.com/Articles/KB000272.aspx