COMMAND

    kernel (MessageBox)

SYSTEMS AFFECTED

    Win NT

PROBLEM

    Jeff Sumner found following.  He has a server app that has several
    clients  attached  to  it.   When  certain  conditions happen on a
    client,  the  server  app  spawns  a  new thread that simply calls
    MessageBox.  The thread is  created so the main server  thread can
    still be processing when the  message box is displayed.   He found
    that when 16  of these threads  are created, NT  pretty much hangs
    until a few of the message boxes are closed.

    There is a  test program to  recreate this (exact  same behavior).
    The test program is a console app that takes an integer  parameter
    for the number of message boxes to pop up.  Running this test  app
    while the  NT performance  monitor up  will show  following.   Any
    number up  to 15  works fine,  but as  soon as  you specify  16 or
    higher, the  task manager  stops dead  cold until  a couple of the
    message boxes (and subsequent threads) are closed.   The code  for
    the     test      program      was     sent      to      following
    newsgroup:microsoft.public.win32.programmer.kernel

SOLUTION

    The MB_SERVICE_NOTIFICATION  flag given  to MessageBox  is causing
    the problem.  This flag allows an NT service to display a  message
    box, regardless of who is logged  in.  The box will still  display
    even if nobody is logged in.   However, NT does not like the  16th
    box at all.  If you take  this flag out, then each message box  is
    created with its own window, and each one appears in the task bar,
    but only if  the "Allow Service  to Interact with  Desktop" option
    is enabled  for the  service under  Control Panel  | Services.  In
    this case, NT  performs fine when  more than 15  message boxes are
    specified, but  no message  boxes will  be displayed  if nobody is
    logged in.  Anyway to bypass, check this key:

        HKLM\SYSTEM\CurrentControlSet\Control\SessionManager\SubSystems\Windows

    The default data for this key:

        %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows
        SharedSection=1024,3072,1024 Windows=On
        SubSystemType=Windows ServerDll=basesrv,1
        ServerDll=winsrv:UserServerDllInitialization,3
        ServerDll=winsrv:ConServerDllInitialization,2
        ProfileControl=Off MaxRequestThreads=16

    So,  if  you  set  MaxRequestThreads=5  the  system  halts  at   5
    messageboxes. It's an ajustable bug...

    I'm not  sure if  following applies  to this,  but I suspect so...
    The patch is available at

        ftp://ftp.microsoft.com/bussys/winnt/winnt-public/fixes/usa/nt40/Hotfixes-PostSP5/CSRSS-fix/