I have an async Library for audio file processing. Furthermore I want to offer these Methods via Rest. So I made an MVC WebApi Project. The library needs some time to start, so I added a class that offers a way to init and exposes the libraries main object.
public static class MusicHandler
{
public static MusicCapture.MusicCapture MusicCapture;
public static void init()
{
MusicCapture = new MusicCapture.MusicCapture("D:\\Temp", "D:\\test", "E:\\FingerPrintDB2.ss");
MusicCapture.Start();
}
}
I start it in Application_Start()
protected void Application_Start()
{
MusicHandler.init();
}
Now when my init method contains some async calls like this:
var hashedFingerprints = command.Hash().Result;
The programm will just skip over these lines. They do not get executed for all I can tell. Same thing happens when I call any of the objects async methods from my REST endpoints. When I run the library not from ASP.NET/MVC the code works flawlessly.
I found some comments that said that this is a problem because of deadlocks, but no advice or code how to avoid this/make this work.
Thank you in advance.