RussellW 3 Posted March 11, 2020 I have an IOmniBackgroundWork in my application and the application closes normally if I don't use it, but if I add a workitem the app hangs when closing. The Teardown is as per the examples: FBackgroundWorker.CancellAll; Result := FBackgroundWorker.Terminate(5000); FBackgroundWorker := Nil; the result is always False (I have tried varying values for Terminate). The workitems are always an interfaced object and always get to the OnRequestDone method so I can't understand why Terminate returns false.. I have tried setting the interface to Nil and also not setting it to Nil in the OnRequestDone method. I think I'm missing something here. Any ideas? Thanks Share this post Link to post
Primož Gabrijelčič 223 Posted March 11, 2020 You are missing a reproducible test case 😉 Sincerely, I have no idea. If the example works for you (you tested it, probably?) and the application doesn't, you'll have to find what that difference is. 1 Share this post Link to post
RussellW 3 Posted March 12, 2020 just working through the code. Given that the Data in the WorkItem is WorkItem.Data.AsInterface = TSomeObject.Create; when would you expect the Object, and the WorkItem to be freed? thanks Share this post Link to post
Primož Gabrijelčič 223 Posted March 12, 2020 When the WorkItem is freed. Usually that happens after it is dispatched to your notification handler (OnRequestDone, OnRequestDone_Asy). Share this post Link to post