Invoking a tooltip from a secundary thread

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thijs

    Invoking a tooltip from a secundary thread

    Hello everybody,

    I´ve got a problem that´s slightly complicated (at least to me it
    seems) so I will try to state it as clearly as possible.

    At a certain point in time, I start a second thread that runs one of
    my functions. The function in this second raises events. As you might
    know, the eventhandler for this event is executed within this second
    thread and not within the first. It´s not possible to update
    properties of a user control (like a label) that was created in the
    first thread, from a second thread. Now .NET has this neat little
    invoke() method on their controls, so that you can still use delegates
    to update these controls.

    So far so good.

    However, I run into problems with one special object: a ToolTip
    instance. I want the eventhandler, executed by the second thread, to
    display a tooltip. However, there is no invoke() method on the
    tooltip, and that makes invoking it quite hard. Calling it directly
    doesn´t work either.

    Does anyone have a solution for this so that I can still show this
    tooltip?

    Kind regards,
    Thijs Brilleman
  • Patrice

    #2
    Re: Invoking a tooltip from a secundary thread

    You could :
    - configure the tooltip so that it is displayed automatically when hovering
    the control if applicable
    - if you want to display explicitely the tool tip, you can use whatever
    Invoke method is available. AFAIK having Invoke on all controls is a
    convenience to avoid going always to the parent form but calling invoke on
    any control that belongs to the form (or the Form.Invoke method) will always
    call on the same UI thread...

    --
    Patrice

    "Thijs" <thijs.brillema n@gmail.coma écrit dans le message de news:
    ab17e785-9e8f-4bf9-a83c-d3bf526c46e5...l egroups.com...
    Hello everybody,

    I´ve got a problem that´s slightly complicated (at least to me it
    seems) so I will try to state it as clearly as possible.

    At a certain point in time, I start a second thread that runs one of
    my functions. The function in this second raises events. As you might
    know, the eventhandler for this event is executed within this second
    thread and not within the first. It´s not possible to update
    properties of a user control (like a label) that was created in the
    first thread, from a second thread. Now .NET has this neat little
    invoke() method on their controls, so that you can still use delegates
    to update these controls.

    So far so good.

    However, I run into problems with one special object: a ToolTip
    instance. I want the eventhandler, executed by the second thread, to
    display a tooltip. However, there is no invoke() method on the
    tooltip, and that makes invoking it quite hard. Calling it directly
    doesn´t work either.

    Does anyone have a solution for this so that I can still show this
    tooltip?

    Kind regards,
    Thijs Brilleman


    Comment

    • Michel Posseth  [MCP]

      #3
      Re: Invoking a tooltip from a secundary thread

      Hello Thijs ,

      You can just use invokerequired and if returned true use a delegate to
      synchronize

      i wrote some examples for this newsgroup in the past

      1.

      2.

      3.



      Wit the examples i show above it should be easy to acomplish what you want ,

      HTH

      Michel Posseth [MCP]



      "Thijs" <thijs.brillema n@gmail.comschr eef in bericht
      news:ab17e785-9e8f-4bf9-a83c-d3bf526c46e5@m3 4g2000hsf.googl egroups.com...
      Hello everybody,

      I´ve got a problem that´s slightly complicated (at least to me it
      seems) so I will try to state it as clearly as possible.

      At a certain point in time, I start a second thread that runs one of
      my functions. The function in this second raises events. As you might
      know, the eventhandler for this event is executed within this second
      thread and not within the first. It´s not possible to update
      properties of a user control (like a label) that was created in the
      first thread, from a second thread. Now .NET has this neat little
      invoke() method on their controls, so that you can still use delegates
      to update these controls.

      So far so good.

      However, I run into problems with one special object: a ToolTip
      instance. I want the eventhandler, executed by the second thread, to
      display a tooltip. However, there is no invoke() method on the
      tooltip, and that makes invoking it quite hard. Calling it directly
      doesn´t work either.

      Does anyone have a solution for this so that I can still show this
      tooltip?

      Kind regards,
      Thijs Brilleman


      Comment

      • Thijs

        #4
        Re: Invoking a tooltip from a secundary thread

        Both of you, thanks a lot. The simple solution Patrice offered turned
        out to be very effective.

        Thijs

        On Feb 11, 8:11 pm, "Michel Posseth [MCP]" <MSDN@posseth.c omwrote:
        Hello Thijs ,
        >
        You can just use invokerequired and if returned true use a delegate to
        synchronize
        >
        i wrote some examples for this newsgroup in the past
        >
        1.http://groups.google.nl/group/micros...anguages.vb/br...
        2.http://groups.google.nl/group/micros...anguages.vb/br...
        3.http://groups.google.nl/group/micros...anguages.vb/br....
        >
        Wit the examples i show above it should be easy to acomplish what you want,
        >
        HTH
        >
        Michel Posseth [MCP]
        >
        "Thijs" <thijs.brillema n@gmail.comschr eef in berichtnews:ab1 7e785-9e8f-4bf9-a83c-d3bf526c46e5@m3 4g2000hsf.googl egroups.com...
        Hello everybody,
        >
        I´ve got a problem that´s slightly complicated (at least to me it
        seems) so I will try to state it as clearly as possible.
        >
        At a certain point in time, I start a second thread that runs one of
        my functions. The function in this second raises events. As you might
        know, the eventhandler for this event is executed within this second
        thread and not within the first. It´s not possible to update
        properties of a user control (like a label) that was created in the
        first thread, from a second thread. Now .NET has this neat little
        invoke() method on their controls, so that you can still use delegates
        to update these controls.
        >
        So far so good.
        >
        However, I run into problems with one special object: a ToolTip
        instance. I want the eventhandler, executed by the second thread, to
        display a tooltip. However, there is no invoke() method on the
        tooltip, and that makes invoking it quite hard. Calling it directly
        doesn´t work either.
        >
        Does anyone have a solution for this so that I can still show this
        tooltip?
        >
        Kind regards,
        Thijs Brilleman

        Comment

        Working...