{"action":"opened","issue":{"url":"https://api.github.com/repos/spinettaro/delphi-event-bus/issues/15","repository_url":"https://api.github.com/repos/spinettaro/delphi-event-bus","labels_url":"https://api.github.com/repos/spinettaro/delphi-event-bus/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/spinettaro/delphi-event-bus/issues/15/comments","events_url":"https://api.github.com/repos/spinettaro/delphi-event-bus/issues/15/events","html_url":"https://github.com/spinettaro/delphi-event-bus/issues/15","id":372270793,"node_id":"MDU6SXNzdWUzNzIyNzA3OTM=","number":15,"title":"Exception error while using Spring4D Dependency injection and multiple UnRegister.","user":{"login":"epachsoft","id":27869756,"node_id":"MDQ6VXNlcjI3ODY5NzU2","avatar_url":"https://avatars0.githubusercontent.com/u/27869756?v=4","gravatar_id":"","url":"https://api.github.com/users/epachsoft","html_url":"https://github.com/epachsoft","followers_url":"https://api.github.com/users/epachsoft/followers","following_url":"https://api.github.com/users/epachsoft/following{/other_user}","gists_url":"https://api.github.com/users/epachsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/epachsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epachsoft/subscriptions","organizations_url":"https://api.github.com/users/epachsoft/orgs","repos_url":"https://api.github.com/users/epachsoft/repos","events_url":"https://api.github.com/users/epachsoft/events{/privacy}","received_events_url":"https://api.github.com/users/epachsoft/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-21T02:02:59Z","updated_at":"2018-10-21T02:02:59Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI'm using Delphi Tokyo, latest version.  I'm using Spring4D container and declaring an IEventBus (not using the built in singleton) as a singleton.\r\n\r\nIn one part of my code I call twice the method to UnRegister the current object.\r\n\r\nE.g.\r\n\r\nif not Assigned(fEventBus) then Exit;  // shouldnt be needed but, hey just in case\r\n\r\nIf fEventBus.IsRegistered(Self) then\r\n fEventBus.UnRegister(Self);  \r\n\r\nCalling this twice will cause an exception.  The exception happens while attempting to Acquire the critical section via FCS.  It seems that the finalization section was already called and the FCS critical section is now nil, causing the issue.\r\n\r\nIn general Finalization sections mixed with Dependency containers will cause trouble.  I will suggest an implementation that completely skips the use of that methodology if the developer is not using the built in singleton.\r\n\r\nThank you for your great work with this, it is extremely useful.  It will be great if you wrap it into a component so its easier to share and it can be exposed via Delphinus or GetIt.\r\n\r\n"}}
{"actor":{"display_login":"epachsoft"}}