Re: lock used in thread and by event




No, this is the issue: first thread is using a method X that uses
lock(X).
Second thread is fireing an event that executes first threads method
that
also uses lock(X).

So is this situation same like e.g. one and only thread is calling
lock(X)
two times and it does not block?

To clearify again ;) is Event call from one thread to another threads
method that uses lock(X) {...} like Java's ReentrantLock?

Cheers!

On 25 syys, 14:45, "Jon Skeet [C# MVP]" <sk...@xxxxxxxxx> wrote:
On Sep 25, 12:37 pm, uupi_...@xxxxxxxxx wrote:

Hello, I can't post the program but code was in previous posting.

Well *some* code was in the previous posting - but nothing to show
what threads are doing what, etc.

But what I would like to know is that is event call executed in caller
thread's context or in the context of that thread were the event
handler code is?

The caller. There's no such thing as "the thread where the event
handler code is".

To clearify: is event call
same as a method call and executed in context of the thread which has
the actual event handler?

Yes.

So, is my example of two different threads using event and same lock-
variable in first thread same thing that what happends when one thead
calls lock(this) too times sequentially (and it does
not start waitiing in second lock call).

It depends on what you mean by "two different threads using event". It
would be *much* easier to talk about this if you could write a short
but complete example. It doesn't need to be your real code - just code
we can talk about.

Jon

.



Relevant Pages

  • Re: vZOOM can handle cross-thread long-term references?
    ... You don't really want a non-polling processor thread to be able to access ... any data on a foreign thread unless you within the context of a memory ... At the end of the entire operation the first thread would contain a 1 in prefs, and the second thread would contain a in prefs. ...
    (comp.programming.threads)
  • [question] read operation problem
    ... I'm writing MPEG program using more than 2 threads. ... First thread read MPEG data from MPEG hardware and write data to file. ... Second thread read file and send data to client program. ...
    (comp.os.linux.development.apps)
  • Re: [question] read operation problem
    ... > I'm writing MPEG program using more than 2 threads. ... > First thread read MPEG data from MPEG hardware and write data to file. ... > Second thread read file and send data to client program. ...
    (comp.os.linux.development.apps)
  • Re: vZOOM can handle cross-thread long-term references?
    ... You don't really want a non-polling processor thread to be able to access ... any data on a foreign thread unless you within the context of a memory ... How first thread pass pointer p to second thread - this is separate ...
    (comp.programming.threads)
  • Re: System.Runtime.InteropServices.InvalidComObjectException: Com object that has been seperated fro
    ... > And in the second thread am trying to read an Excel file. ... > smoothly.Its in the first thread am facing the error: ... > user, String password, String authority, Int32 impersonationLevel, Int32 ...
    (microsoft.public.dotnet.framework)

Loading