E
etl2016
Guest
hi,
As I understand it, multithreading is for getting full potential of machine's processing capacity by splitting cpu-bound workload. And, Asynchronous programming is to get best use of clock-time to carry on independent tasks simultaneously. Am trying to integrate these two features to address scenarios of large scale data processing, where both methods are helpful. But, am not finding many best practices about such an approach (could be that, this approach is discouraged in the first place - so, please feedback - thanks)
The below code setup is throwing an object reference error: Is this design approach correct, if so, could you please suggest a fix to the error, thanks.
using System;
using System.Threading;
using System.Threading.Tasks;
namespace threadAsync
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("MAIN : Hello World!");
Calling_method_async();
}
private async void Calling_method_async()
{
var th = new Thread(async () => await Called_method_async());
th.Start();
}
public async Task<int> Called_method_async()
{
await Task.Delay(4);
return 42;
}
}
}
Continue reading...
As I understand it, multithreading is for getting full potential of machine's processing capacity by splitting cpu-bound workload. And, Asynchronous programming is to get best use of clock-time to carry on independent tasks simultaneously. Am trying to integrate these two features to address scenarios of large scale data processing, where both methods are helpful. But, am not finding many best practices about such an approach (could be that, this approach is discouraged in the first place - so, please feedback - thanks)
The below code setup is throwing an object reference error: Is this design approach correct, if so, could you please suggest a fix to the error, thanks.
using System;
using System.Threading;
using System.Threading.Tasks;
namespace threadAsync
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("MAIN : Hello World!");
Calling_method_async();
}
private async void Calling_method_async()
{
var th = new Thread(async () => await Called_method_async());
th.Start();
}
public async Task<int> Called_method_async()
{
await Task.Delay(4);
return 42;
}
}
}
Continue reading...