I have a non-static class and a static method inside it. No doubts so far. but I create an instance of the same class in the static method. I am not sure, whether it will create a circular reference. I ran it in debug mode to see any unexpected behavior, but couldn't. However, I want to confirm this. Is it ok to create an instance of a class inside a static method in the same class? Is it a bad habit?
public class DownloadHelper
{
//fields, properties
public DownloadHelper()
{
// some code
}
public async Task<bool> HttpCalls()
{
await Task.Delay(1000);
return true;
}
public static async void GetPreparedInAdvance()
{
var helper = new DownloadHelper();
var success = await helper.HttpCalls();
// some more codes
}
}
// Is it ok to call like this?
DownloadHelper.GetPreparedInAdvance();
// little later,
DownloadHelper.GetPreparedInAdvance();