Re: Why Thread-Safe VB6 ActiveX when it is single threaded?



..Suchit <Suchit@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> (+) Suppose different threads call Advise(..) on a Global
> Interface Table registered pointer; and the call method with
> different parameters:
>
> **** When the processing is done, the argument 1 data is avaialble.
> When VisualBasic calls RaiseEvent() .. will all the threads get back
> this result Event for argument 1? I mean will EventSinkMethod() be
> called for all sink objects in various threads? ****

Yes, VB broadcasts an event to all attached sinks. If you want a
per-operation callback, event sink is a wrong mechanism. Instead, you
should pass the callback interface as part of the job parameters:

pMyControl->DoSomething(param, pMyCallback);

The control would then perform the operation asynchronously, and call a
method on the callback interface when done.

By the way, is the control's method indeed asynchronous? Because if it's
not (you call it, it performs its action and only then returns from the
call) you don't need any events or callbacks. Just call the method, your
thread will sit there waiting for it to complete, then any output could
be communicated back to you through parameters.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Invalid callback object instance
    ... For asynchronous operations I use ... a callback interface to notify the application of completions. ... I receive as the first parameter (caller) is not valid. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Callback Interface functions NOT being Called
    ... a callback interface interface ICallbackInterface which implements the ... of the same interface in one object, IDispatch in your case. ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: IRibbonExtensibility integration issue for unmanaged AddIn
    ... Sadly it did work at first, but now for some reason the Callback Interface isn't accessed anymore at all. ... As there are no error messages for onAction as well as loadImage methods i guess Outlook doesn't even call the callback interfaces Invoke-implementation. ... interface ICallbackInterface; ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: Multiple Sinks
    ... I think I have to define a callback interface ... The client has to implement this interface and pass it to ... > talking here about the interface of each device object, ...
    (microsoft.public.vc.atl)
  • Re: getting an event handler from a active-x dll dispinterface
    ... Connect (const ASource: IUnknown); ... fire events through it if it is. ... Calling a method on the event sink object to connect the source? ... to have a method to pass the event sink object('s interface) to. ...
    (alt.comp.lang.borland-delphi)