As the title asks. Let's say I have the below code, where three tasks are being run concurrently. Let's also say that within each task, they are calling a single, shared RestClient instance and sending requests to the RingCentral API to gather various information.
Is this thread safe to have multiple threads making calls concurrently using the same RestClient instance? I have read that in a plain HttpClient instance, it would be thread safe if the requests were the 'async' version of those requests, ie, GetAsync(), PostAsync, etc. It's not immediately clear if the RingCentral API's RestClient class is working in that manner.
public async Task MainTask()
{
Task[] tasks = new Task[3];
tasks[0] = new Task(() => asyncMethod1());
tasks[1] = new Task(() => asyncMethod2());
tasks[2] = new Task(() => asyncMethod3());
Task.WaitAll(tasks);
}
public async Task asyncMethod1()
{
//do stuff using a shared RestClient instance
}
public async Task asyncMethod2()
{
//do stuff using a shared RestClient instance
}
public async Task asyncMethod3()
{
//do stuff using a shared RestClient instance
}