Results 1 to 6 of 6

Thread: [2005] Make a function wait for an event before returning value

  1. #1

    Thread Starter
    Addicted Member Latin4567's Avatar
    Join Date
    Jan 2005
    Posts
    202

    Exclamation [2005] Make a function wait for an event before returning value

    I was putting the finishing touches on my widget engine and I encountered a rather annoying problem. My engine has a custom MsgBox function which overrides the framework's msgbox function once the engine has been imported into a solution. To make a long story short, my msgbox function shows a 'widget' object which is the size of a msgbox and has buttons, text.. etcetera... One of the defining features of a msgbox, is that it stops whatever is currently processing and waits for the user to click a button. Now normally I would just use the showdialog function on my widget and use a with statement to detect when the dialogresult value has been set. The problem is, showdialog messes up the parent/child relationships of my widgets so I am forced to use show(), which does not produce a value. Therefore I will have to somehow force my MsgBox function to wait for the OnClick event of one of its buttons BEFORE returning a value. How can I do this? Multi-Threading?

    help

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Make a function wait for an event before returning value

    Is this for Yahoo widgets?

    You could do many things, but that may lead to more complex solutions... maybe you should describe the parent child relationships.

  3. #3

    Thread Starter
    Addicted Member Latin4567's Avatar
    Join Date
    Jan 2005
    Posts
    202

    Re: [2005] Make a function wait for an event before returning value

    no its for my own widget engine that I made.... child objects are actually popup windows so the showdialog function screws them up

    basically i need to figure out how to block the calling thread and wait for a form to close before resuming (emulate the showdialog function)

  4. #4

    Thread Starter
    Addicted Member Latin4567's Avatar
    Join Date
    Jan 2005
    Posts
    202

    Re: [2005] Make a function wait for an event before returning value

    i figured it out.... the startposition property of my main form was screwing things up... i just set it to manual and the children windows work with the showdialog function again

  5. #5
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: [2005] Make a function wait for an event before returning value

    VB Code:
    1. Public Class Form1
    2.     Private SomeEventRaised As Boolean = False
    3.     Private Sub SomeOperation()
    4.         'code
    5.         While SomeEventRaised <> True
    6.         End While
    7.         'The event was raised, go on
    8.     End Sub
    9.     Private Sub EventHandler(ByVal sender As Object, ByVal e As System.EventArgs) Handles SomeObject.Event
    10.         SomeEventRaised = True
    11.     End Sub
    12. End Class
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  6. #6

    Thread Starter
    Addicted Member Latin4567's Avatar
    Join Date
    Jan 2005
    Posts
    202

    Re: [2005] Make a function wait for an event before returning value

    ..that makes it hang. I figured this out a while ago tho. Thx

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