I have a process that runs every two min and execute the method.
Sometimes, the process takes more than two min. In this case, I want the process to wait until the process is completed.
My code looks as below. I tried lock, monitor but none working because of async-await. I am getting this error SynchronizationLockException on Monitor.Exit when using await
public async Task RunProcess()
{
await GetRecords();
await CheckDuplicates();
await InsertRecords();
}
What is the best practice to implement this?