List Info

Thread: UI Marshall - Virtual Methods




UI Marshall - Virtual Methods
user name
2006-06-07 23:58:05
Yes your method would continue on ..

BeginInvoke will simply call PostMessage queuing the message
to tell the
main thread to get to it eventually ...

Invoke does the exact same thing except it blocks for
completion (it does
not use SendMessage as some articles out there would lead
you to believe)

Deadlocks also exist with Control.Invoke()

You background thread is holding a resource, it posts a
message back to the
main thread to do a task. The main thread is blocking on the
thread to
release the resource (possibly for a completely unrelated
message).. The
background thread is blocking on the main thread to complete
...

I believe Ian has a post about that on his blog as well
"What locks am I
holding" off the top of my head ...

Cheers,

Greg
On 6/7/06, Vince P <vincep1974comcast.net> wrote:
>
> Thanks Peter .. though I think my question is concrete
enough to stand as
> it
> was...   is the way the methods are setup such that the
UI thread will be
> marshaled to if another thread calls it?
>
> The reason I said I think I need to do an invoke is
because if
>
> Derived.Method is called by Thread Non-UI,
>
> Derived.Method is going to call to Base.Method
>
> Now if Base.Method is doing BeginInvoke, isn't
Derived.Method going to
> keep
> running concurrently while Base.Method is doing
BeginInvoke marshalling?
>
> I would need the marshalling to be complete before
allowing Derived.Method
> to go on, if my understanding of all this is right.
>
> I'm interested in your view on this, thanks.
>
> ---
> Vince
> > -----Original Message-----
> > From: Discussion of development on the .NET
platform using any managed
> language
> > [mailtoOTNET-CL
RDISCUSS.DEVELOP.COM] On Behalf Of Peter Ritchie
> > Sent: Wednesday, June 07, 2006 9:12 AM
> > To: DOTNET-CLRDISCUSS.DEVELOP.COM
> > Subject: Re: [DOTNET-CLR] UI Marshall - Virtual
Methods
> >
> > A virtual relationship is a language construct; it
has nothing to do
> with
> windows or
> > forms and won't do any "automatic
marshaling" of data or threads
> contexts.
> >
> > BTW, using BeginInvoke() is preferred over
Invoke() because Invoke()
> leaves you
> > open for race conditions.
> >
> > See Ian Griffiths comments on Begin/BeginInvoke at
> > http://msdn.microsoft.com/msdnmag/issues/03/02/Mul
tithreading/
> >
> > On Wed, 7 Jun 2006 05:52:02 -0500, Vince P
<vincep1974COMCAST.NET>
> wrote:
> >
> > >I managed to confuse myself.
> > >
> > >
> > >
> > >
> > >
> > >Will this type of relationship between base
and derived Windows Form
> > >class properly Marshall the running thread for
the virtual method call
> > >(provided that base.Method(X) is called first
in any override) ?
> > >
> > >
> > >
> > >class Base
> > >
> > >{
> > >
> > >
> > >
> > >protected delegate void
FormatDepartedUsersDelegate(string userName);
> > >
> > >protected virtual void
FormatArrivedUsers(string userName)
> > >
> > >{
> > >
> > >  if (this.InvokeRequired) {
> > >
> > >    this.BeginInvoke(new
> >
>FormatArrivedUsersDelegate(this.FormatArrivedUsers), new
> > >object[]);
> > >
> > >  }
> > >
> > >  else {
> > >
> > >    .
> > >
> > >  }
> > >
> > >}
> > >
> > >}
> > >
> > >
> > >
> > >
> > >
> > >class Derived : Base
> > >
> > >{
> > >
> > >
> > >
> > >protected override void
FormatArrivedUsers(string userName)
> > >
> > >{
> > >
> > >base.FormatArrivedUsers(userName);
> > >
> > >.
> > >
> > >}
> > >
> > >}
> >
> > ===================================
> > This list is hosted by DevelopMentorR  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> http://discuss.develop.com

>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com

>



--
If knowledge can create problems, it is not through
ignorance that we can
solve them.

Isaac Asimov

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

UI Marshall - Virtual Methods
user name
2006-06-08 00:18:55
Maybe I should back up..

What's the best way to handle UI Marshalling for virtual
methods?

Should each implementation of the method do it's own
Marshalling and not
rely on the base method to do so?

Thinking about this, it's probably the best solution.

---
Vince

> -----Original Message-----
> From: Discussion of development on the .NET platform
using any managed
language
> [mailtoOTNET-CL
RDISCUSS.DEVELOP.COM] On Behalf Of gregory young
> Sent: Wednesday, June 07, 2006 6:58 PM
> To: DOTNET-CLRDISCUSS.DEVELOP.COM
> Subject: Re: [DOTNET-CLR] UI Marshall - Virtual Methods
>
> Yes your method would continue on ..
>
> BeginInvoke will simply call PostMessage queuing the
message to tell the
main
> thread to get to it eventually ...
>
> Invoke does the exact same thing except it blocks for
completion (it does
not use
> SendMessage as some articles out there would lead you
to believe)
>
> Deadlocks also exist with Control.Invoke()
>
> You background thread is holding a resource, it posts a
message back to
the main
> thread to do a task. The main thread is blocking on the
thread to release
the
> resource (possibly for a completely unrelated
message).. The background
thread is
> blocking on the main thread to complete ...
>
> I believe Ian has a post about that on his blog as well
"What locks am I
holding" off
> the top of my head ...
>
> Cheers,
>
> Greg
> On 6/7/06, Vince P <vincep1974comcast.net> wrote:
> >
> > Thanks Peter .. though I think my question is
concrete enough to stand
> > as it
> > was...   is the way the methods are setup such
that the UI thread will
be
> > marshaled to if another thread calls it?
> >
> > The reason I said I think I need to do an invoke
is because if
> >
> > Derived.Method is called by Thread Non-UI,
> >
> > Derived.Method is going to call to Base.Method
> >
> > Now if Base.Method is doing BeginInvoke, isn't
Derived.Method going to
> > keep running concurrently while Base.Method is
doing BeginInvoke
> > marshalling?
> >
> > I would need the marshalling to be complete before
allowing
> > Derived.Method to go on, if my understanding of
all this is right.
> >
> > I'm interested in your view on this, thanks.
> >
> > ---
> > Vince
> > > -----Original Message-----
> > > From: Discussion of development on the .NET
platform using any
> > > managed
> > language
> > > [mailtoOTNET-CL
RDISCUSS.DEVELOP.COM] On Behalf Of Peter Ritchie
> > > Sent: Wednesday, June 07, 2006 9:12 AM
> > > To: DOTNET-CLRDISCUSS.DEVELOP.COM
> > > Subject: Re: [DOTNET-CLR] UI Marshall -
Virtual Methods
> > >
> > > A virtual relationship is a language
construct; it has nothing to do
> > with
> > windows or
> > > forms and won't do any "automatic
marshaling" of data or threads
> > contexts.
> > >
> > > BTW, using BeginInvoke() is preferred over
Invoke() because Invoke()
> > leaves you
> > > open for race conditions.
> > >
> > > See Ian Griffiths comments on
Begin/BeginInvoke at
> > > http://msdn.microsoft.com/msdnmag/issues/03/02/Mul
tithreading/
> > >
> > > On Wed, 7 Jun 2006 05:52:02 -0500, Vince P
<vincep1974COMCAST.NET>
> > wrote:
> > >
> > > >I managed to confuse myself.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >Will this type of relationship between
base and derived Windows
> > > >Form class properly Marshall the running
thread for the virtual
> > > >method call (provided that base.Method(X)
is called first in any
override) ?
> > > >
> > > >
> > > >
> > > >class Base
> > > >
> > > >{
> > > >
> > > >
> > > >
> > > >protected delegate void
FormatDepartedUsersDelegate(string
> > > >userName);
> > > >
> > > >protected virtual void
FormatArrivedUsers(string userName)
> > > >
> > > >{
> > > >
> > > >  if (this.InvokeRequired) {
> > > >
> > > >    this.BeginInvoke(new
> > >
>FormatArrivedUsersDelegate(this.FormatArrivedUsers), new
> > > >object[]);
> > > >
> > > >  }
> > > >
> > > >  else {
> > > >
> > > >    .
> > > >
> > > >  }
> > > >
> > > >}
> > > >
> > > >}
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >class Derived : Base
> > > >
> > > >{
> > > >
> > > >
> > > >
> > > >protected override void
FormatArrivedUsers(string userName)
> > > >
> > > >{
> > > >
> > > >base.FormatArrivedUsers(userName);
> > > >
> > > >.
> > > >
> > > >}
> > > >
> > > >}
> > >
> > > ===================================
> > > This list is hosted by DevelopMentorR  http://www.develop.com
> > >
> > > View archives and manage your subscription(s)
at
> > http://discuss.develop.com

> >
> > ===================================
> > This list is hosted by DevelopMentor(r)  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> > http://discuss.develop.com

> >
>
>
>
> --
> If knowledge can create problems, it is not through
ignorance that we can
solve
> them.
>
> Isaac Asimov
>
> ===================================
> This list is hosted by DevelopMentorR  http://www.develop.com
>
> View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )