I do not know your exact scenario, but first of all if you use unmanaged resources in your application, you might prefer to separate this in a different component (e.g. a service) to have a complete control of its disposal. Otherwise,
you depend on the garbage collection and it not possible to predict when it will occur.
On the specific subject of resource management, you need to ensure that your unmanaged resources are released. The way to do this is by implementing
IDisposable correctly, as it explained in the code sample from
this MSDN article.
This way, you would be able to handle the component’s disposal manually, as it shown
here. For example, if you opt to use a service, the call should look like the following:
using (var myService = container.Resolve<MyService>())
For more information on how to implement the Dispose method, you could check the following documentation sections:
Please let me know if this helps.