By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,197 Members | 1,445 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,197 IT Pros & Developers. It's quick & easy.

event handler signature private/public?

P: n/a
I have an event handler inside a thread class that needs to have access to
thread specific information (versus similar info in other threads). If I
change the handler's method signature to "public" from "private" VS05 "sees"
the instance variables I want.

My question is, is this "cheating" that will break or cause some problems
down the road? Or can I get away with it? Thanks!

Regards,
Raj
Apr 3 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
what are you trying to achieve by exposing them to a public?? If you are
looking for a communication of the thread back to the object that created
it.. use events to send information out to calling object, making public is
probably not the perfect OO way to do it.. Also put the code in the event in
a method, make that public, not the event itself. This way you can even call
it from else where...

Vijay

"Raj Wall" <me********@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have an event handler inside a thread class that needs to have access to
thread specific information (versus similar info in other threads). If I
change the handler's method signature to "public" from "private" VS05
"sees" the instance variables I want.

My question is, is this "cheating" that will break or cause some problems
down the road? Or can I get away with it? Thanks!

Regards,
Raj

Apr 3 '06 #2

P: n/a
Hi,

Can you provide an example of what you mean?

The visibility of the method has nothing to do with what it can access. It's
still a member of the class and so has access to all the instances variables
and members.

The only difference is if it's declared public it can be called from the
outside.

Could you post both method signatures?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Raj Wall" <me********@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have an event handler inside a thread class that needs to have access to
thread specific information (versus similar info in other threads). If I
change the handler's method signature to "public" from "private" VS05
"sees" the instance variables I want.

My question is, is this "cheating" that will break or cause some problems
down the road? Or can I get away with it? Thanks!

Regards,
Raj

Apr 3 '06 #3

P: n/a
Ignacio, Vijay, hi,
Thanks for the response. The event I'm trying to catch is the file-created
event from the FileSystemWatcher. My event handling method,
private void OnCreated(object source, FileSystemEventArgs e)

is in my ThreadWithState. Each instance of the thread has an associated
ActiveX component that the event handler needs to reach. So, I should be
able to reference thread instance variables from "inside" the event handler
method, correct? Thanks, and sorry for my confusion.

Regards,

Raj

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%2****************@tk2msftngp13.phx.gbl...
Hi,

Can you provide an example of what you mean?

The visibility of the method has nothing to do with what it can access.
It's still a member of the class and so has access to all the instances
variables and members.

The only difference is if it's declared public it can be called from the
outside.

Could you post both method signatures?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Raj Wall" <me********@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have an event handler inside a thread class that needs to have access to
thread specific information (versus similar info in other threads). If I
change the handler's method signature to "public" from "private" VS05
"sees" the instance variables I want.

My question is, is this "cheating" that will break or cause some problems
down the road? Or can I get away with it? Thanks!

Regards,
Raj


Apr 4 '06 #4

P: n/a
Hi Raj,

As long as event handler function is the ThreadWithstate class's member
function ,it certainly can access the associated class instance's other
member variables. It is only when we will let other class instance's
function directly access a certain member of our custom class shall we make
that member "public".

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Apr 5 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.