Thread exits immediately with no reason.

Ali Çehreli acehreli at yahoo.com
Tue Dec 21 18:22:32 UTC 2021


On 12/21/21 10:07 AM, solidstate1991 wrote:

 > I couldn't add those lines unfortunately,

Perhaps I had typos? Or the code is not yours to modify? In any case, 
you should be able to introduce a top level thread entry function and 
put the try-catch in there.

 > but I do get an exception in a
 > destructor at line 218 of `wasapi.d`. It's access violation executing a
 > location.

If garbage-collected objects are involved, it may be because destructors 
are executed at indeterminate times, potentially after their members are 
destroyed. I haven't studied the code to be sure but for example, 
eventHandle may have already been destroyed when executing the following 
line:

 
https://github.com/ZILtoid1991/iota/blob/main/source/iota/audio/wasapi.d#L218

A solution is to manage the destruction of objects at known times e.g. 
by calling destroy() explicitly.

Ali



More information about the Digitalmars-d-learn mailing list