G
Grant Johnson
Hello,
I've run across an application design problem I was hoping someone may
have some thoughts on.
I have some .NET code (C#) that uses a third party API (using COM
Interop) to convert email messages. The application has to convert
potentially thousands of messages.
Under some circumstances, the API freezes on a (presumably) dud email
message and never returns. I don't get any notifications of the freeze.
I can't have this happen in a production environment, so was trying to
come up with a design to simply log these events and move on.
Initially I was going to run the API conversion in a new thread, and
Join() the thread with a timeout value. This appeared to be simple
enough. However, the API preclude the use of free-threading - I can't
pass the RCW object from the thread it was created on the to the new
joined thread.
I considered creating a new AppDomain to run the conversion in, and
Unload the AppDomain after a reasonable amount of time. However, I'm
not sure how to design this so I can create an AppDomain in the primary
thread, then monitor it for some pre-determined period of time, finally
Unloading it if the API (instantiated in the AppDomain) doesn't return.
I would really appreciate any thoughts anyone may have.
Regards,
Grant
I've run across an application design problem I was hoping someone may
have some thoughts on.
I have some .NET code (C#) that uses a third party API (using COM
Interop) to convert email messages. The application has to convert
potentially thousands of messages.
Under some circumstances, the API freezes on a (presumably) dud email
message and never returns. I don't get any notifications of the freeze.
I can't have this happen in a production environment, so was trying to
come up with a design to simply log these events and move on.
Initially I was going to run the API conversion in a new thread, and
Join() the thread with a timeout value. This appeared to be simple
enough. However, the API preclude the use of free-threading - I can't
pass the RCW object from the thread it was created on the to the new
joined thread.
I considered creating a new AppDomain to run the conversion in, and
Unload the AppDomain after a reasonable amount of time. However, I'm
not sure how to design this so I can create an AppDomain in the primary
thread, then monitor it for some pre-determined period of time, finally
Unloading it if the API (instantiated in the AppDomain) doesn't return.
I would really appreciate any thoughts anyone may have.
Regards,
Grant