473,395 Members | 1,464 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,395 software developers and data experts.

event handler signature private/public?

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
4 1953
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
2
by: Marinos Christoforou | last post by:
Sorry if this has been asked before but as an inexperienced wanna-be C# programmer I wondering how to code classes to help build a standard Windows UI. For example to build a common toolbar. I...
2
by: Wavemaker | last post by:
The canonical way of declaring delegates for events is to include a parameter representing the sender as well as an EventArgs derived class (or EventArgs itself) as the second parameter...
5
by: J McD | last post by:
Hi I have a DataGrid with an ImageButton column. When I click on an imagebutton I get a postback but it doesn't run the OnImgBtnClick method. I can actually comment out the line where I add this...
4
by: The Alchemist | last post by:
I am having a problem with a dynamically-generated Datagrid. It is important to point out that this problem does not exist with a design-time created Datagrid, but only with a dynamically generated...
4
by: EvelynAnd Ethan | last post by:
Hi, ItemCommand event not firing from a dynamic user control ,WHERE A DATAGRID HAS BUTTON,when i click on the linkbutton first time the itemcommand event doesnt fire,second time event fires up ...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
4
by: tshad | last post by:
I am just getting started with events and had a couple of questions on why they do what they do. If you have a textbox and you want to handle an event you can just do: ...
10
Plater
by: Plater | last post by:
I'm a bit boggled by this since I am rather new to using reflection. I want to attach an event handler via Reflection (which I can do), but I want to NOT have to know the exact event delegate...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.