Using CreateThread in a DLL

Just starting out? Need help? Post your questions and find answers here.
Worm
User
User
Posts: 20
Joined: Wed Apr 14, 2004 2:32 am
Location: Grand Rapids, MI
Contact:

Using CreateThread in a DLL

Post by Worm »

I'd like to show a non modal dialog from within a DLL. Is using CreateThread safe this way? Should I use a Mutex? Should I use the /THREAD commandline when compiling the DLL? As you can see I'm a little fuzzy on what my best options are.

Code: Select all

Global nThread

Procedure NonModalDlg(Value)
  If OpenWindow(0, 216, 0, 350, 167, "Example Window",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(0))
      StringGadget(0, 100, 60, 230, 30, "")
      ButtonGadget(0, 270, 110, 60, 30, "Click Me")
    EndIf
    
    Repeat
      Event = WaitWindowEvent()
      

    Until Event = #PB_Event_CloseWindow
  EndIf
EndProcedure

ProcedureCDLL ShowDlg()
     nThread = CreateThread(@NonModalDlg, 0)
EndProcedure