[Mono-dev] Delay on App Exit?

Rick Tillery rtillerywork at gmail.com
Fri Oct 27 13:42:29 UTC 2017

I have an app running via mono ( on Linux (CentOS 6 & 7) that
creates a (complicated) object with a main thread, starts the main thread,
waits for a SIGINT or SIGTERM (using Mono.Posix.dll), then stops the main
thread, and exits.  But upon exit, after all the code has executed, there
is a delay, typically around 1 minute, but ranging from 16 seconds to 1 1/2

There are no exceptions thrown, no errors indicated in any log I can find.

I have been told that an app can delay on exit in Windows .Net assemblies
if a thread is hung.  There is a timeout to wait, then the app aborts.  So
I have been trying to see if that's what is happening here.
 (Unfortunately, the Windows use of the object must be different, and the
issue does not occur there.)

However, it seems we don't have much visibility into the running mono

Process.GetCurrentProcess().Threads.Count appears to return the thread
count (see below), but the ProcessThread list available
through Process.GetCurrentProcess().Threads contains all null pointers.  I
tried parsing directly
accessing the enumerator directly, and using the CopyTo() method.

In my app, before creating the
object, Process.GetCurrentProcess().Threads.Count indicates there are 3
threads.  I find this same number if I create a simple stand-alone app as

After creating the object, there are 4 threads.

After disposing of the object (using the using command), there are still 4

I thought this lingering thread might be related to the exit delay, but
without visibility into the actual thread details, I can't be sure which
thread is the extra one.

It was mentioned that there may be threads associated with registry
access.  And if I add registry access to my stand-alone app, I also see a
4th thread appear.  But the stand-alone app doesn't hang.

Can anyone suggest a way to determine what the app is doing during the
delay on exit?
Is there a way to get actual details (like the component) for the mono

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20171027/d28f3bea/attachment.html>

More information about the Mono-devel-list mailing list