0

We have a .NET web api controller in c# from which I create a background thread to call a long running method in a dll. the long running method gets a delegate as a parameter. it seems like after a while that delegate is being collected which leads to an access violation exception. How can I prevent the garbage collector from collecting/rewriting that memory?

Thanks

Sina
  • 1,632
  • 3
  • 15
  • 21
  • 1
    You normally put the delegate in a static variable: `static SomeDelegate MySomeDelegate = ...`. If you look around it is explained in many places. – xanatos Jun 22 '18 at 14:22
  • And https://stackoverflow.com/a/25973343/613130 – xanatos Jun 23 '18 at 09:25

0 Answers0