Results 1 to 8 of 8

Thread: msgbox in new thread?!?!

  1. #1

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Posts
    61

    Question msgbox in new thread?!?!

    is it possible to send paratmeters into a thread? i want to show a messagebox in another thread, and get the body of the messagebox from the oldthread , how can i do this?!

    i dont want my program to stop while messagebox is shown, plz tell me how can i do it? if threading , how can i pass the body into the thread? or is there other ways


    thanks,

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Play around with the example Edneeis posted here : http://www.vbforums.com/showthread.p...ight=threading

  3. #3

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Posts
    61
    i didnt get much of the thread you linked me to, and ednees link had problems, i didnt see it, the question is can a thread access a public field of another thread?!

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    If all you are trying to prevent is your application stopping when you show a message box, then why don't you just build a small form that looks like a message box. Then you can just show it by calling the .Show() method and not the .ShowDialog() method. This will show the new form (your custom message box) and continue executing code.

  5. #5

    Thread Starter
    Registered User
    Join Date
    Apr 2003
    Posts
    61
    yeah , that would work for what i'm doing now, but i think i can use this thread thing later on allot, i mean its that hard to pass a parameter to a thread?

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    It isn' hard to pass parameters to a thread you just have to use a delegate. My site is down right now sort of (DNS hasn't switched yet) but I did post a Msgbox example at the bottom of that thread.

    This is the equavilant link for now:
    http://old.isharecode.com/Code/BeginInvoke.asp
    Last edited by Edneeis; Sep 21st, 2003 at 12:21 PM.

  7. #7
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    If you start a thread by:

    VB Code:
    1. Dim myThread = New Thread(New ThreadStart(AddressOf MyMethod))
    2.             myThread.Start()

    Do you have to also stop it at some point?

    VB Code:
    1. myThread.Stop()

    If so, then if I use a delegate, with BeginInvoke, will the thread stop on it's own??

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by VBCrazyCoder
    If you start a thread by:

    VB Code:
    1. Dim myThread = New Thread(New ThreadStart(AddressOf MyMethod))
    2.             myThread.Start()

    Do you have to also stop it at some point?

    VB Code:
    1. myThread.Stop()

    If so, then if I use a delegate, with BeginInvoke, will the thread stop on it's own??
    2-It's just a pointer to a method . When using BeginInvoke and you want to return a value , then use Callback EndInvoke , otherwise I don't think it's needed (it will stop on its own) .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width