473,387 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Access method variables/functions from Event call

Ok i understand the fact that once events are raised they are executed
on another thread and have no access to member functions or variables
because they are static functions.

But i am having trouble how i can Invoke these methods from the static
method.

Can anyone help me out here? :)

TIA!

Jun 5 '07 #1
2 1872
Ahmed,

This isn't true. Events are executed on the thread that they are raised
on. When the events are fired on another thread, it is because they are
raised on that thread.

Also, event handlers can be static methods, or instance methods. You
can attach an event handler to an instance method, and then access all the
members of that instance in the event handler (since it is just another
member).

So instead of attaching to a static method, why not attach to an
instance method which has access to the members you need?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ahmed" <ah*****@gmail.comwrote in message
news:11**********************@x35g2000prf.googlegr oups.com...
Ok i understand the fact that once events are raised they are executed
on another thread and have no access to member functions or variables
because they are static functions.

But i am having trouble how i can Invoke these methods from the static
method.

Can anyone help me out here? :)

TIA!
Jun 5 '07 #2
wow you are right! Ok my book on C# is really misleading and all its
templates are based on static functions which led me to believe it HAD
to be a static function.

Thanks for the help! :)
Ahmed

On Jun 5, 5:21 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Ahmed,

This isn't true. Events are executed on the thread that they are raised
on. When the events are fired on another thread, it is because they are
raised on that thread.

Also, event handlers can be static methods, or instance methods. You
can attach an event handler to an instance method, and then access all the
members of that instance in the event handler (since it is just another
member).

So instead of attaching to a static method, why not attach to an
instance method which has access to the members you need?

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Ahmed" <ahme...@gmail.comwrote in message

news:11**********************@x35g2000prf.googlegr oups.com...
Ok i understand the fact that once events are raised they are executed
on another thread and have no access to member functions or variables
because they are static functions.
But i am having trouble how i can Invoke these methods from the static
method.
Can anyone help me out here? :)
TIA!

Jun 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: quo | last post by:
two questions: 1) Does this program demonstrate the basic difference between public and private access? It appears correct to say that instances of a class cannot directly call a private...
11
by: Roger Leigh | last post by:
The C++ book I have to hand (Liberty and Horvath, Teach yourself C++ for Linux in 21 Days--I know there are better) states that "static member functions cannot access any non-static member...
7
by: Joakim Braun | last post by:
Why doesn't the below code work? I'm trying to create a global object and set an event handler to one of its methods. The function is called, but the object's mTest property is undefined. ...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
5
by: Colin Anderson | last post by:
I discovered, with great excitement, this article http://www.davison.uk.net/vb2notes.asp when researching methods for emailing from Access via Notes. Unfortunatly, when I run this I get a...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
6
by: David Sullivan | last post by:
Hi I have a problem with a database where certain users are closing access (by clicking on the X in top right-hand corner) instead of using a command button before they fill in all relevant...
2
by: Jon Hyland | last post by:
This might be a dumb question, but what is the best way for one instance of a user control to access properties of an instance of another user control? For example, let's say I have an instance...
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.