Click here to Skip to main content
15,907,281 members
Home / Discussions / C#
   

C#

 
QuestionPassing a reference to a volatile value Pin
PIEBALDconsult3-Jan-10 16:49
mvePIEBALDconsult3-Jan-10 16:49 
For a little something I'm just playing around with today I need the ability for an instance to query the state of one or more other instances.
The various instances will therefore be chained together by some technique.
The important thing about this is that the state of the referenced (source) instance can change and the referencing (client) instance should always receive the current state.

A.Input = B.Output
B.Input = C.Output

A should always know the current state of C.Output


Passing the state by value won't work. I thought about using events, but I don't think they're appropriate for the task.

In C (or C++) I might pass the address (or a reference) to the state value, but that's not easily done in C# and I want it to be read-only to the client.


What I've come up with as a workable technique is delegates, which makes sense, I really want callback functions.

In the above example, C provides a delegate to a method that B passes along to A and A can call to get the state of C.

This works fine, and I'm just wondering whether or not anyone else has done anything like this and how they accomplished it.
AnswerRe: Passing a reference to a volatile value Pin
Luc Pattyn3-Jan-10 17:04
sitebuilderLuc Pattyn3-Jan-10 17:04 
GeneralRe: Passing a reference to a volatile value Pin
PIEBALDconsult4-Jan-10 3:10
mvePIEBALDconsult4-Jan-10 3:10 
GeneralRe: Passing a reference to a volatile value Pin
PIEBALDconsult7-Jan-10 4:23
mvePIEBALDconsult7-Jan-10 4:23 
GeneralRe: Passing a reference to a volatile value Pin
Luc Pattyn7-Jan-10 4:30
sitebuilderLuc Pattyn7-Jan-10 4:30 
QuestionQuick way to switch the scopes of 2 code blocks? Pin
sherifffruitfly3-Jan-10 16:22
sherifffruitfly3-Jan-10 16:22 
AnswerRe: Quick way to switch the scopes of 2 code blocks? Pin
PIEBALDconsult3-Jan-10 16:23
mvePIEBALDconsult3-Jan-10 16:23 
QuestionTrying to open a new tab(User control embedded) Pin
xEvOx3-Jan-10 14:44
xEvOx3-Jan-10 14:44 
Questionwhere i can learn the basic of class - as simple as i can (C#) Pin
E_Gold3-Jan-10 9:17
E_Gold3-Jan-10 9:17 
AnswerRe: where i can learn the basic of class - as simple as i can (C#) Pin
Luc Pattyn3-Jan-10 11:03
sitebuilderLuc Pattyn3-Jan-10 11:03 
Questionsending Form to User Control that has written in another project Pin
jojoba20103-Jan-10 4:38
jojoba20103-Jan-10 4:38 
AnswerRe: sending Form to User Control that has written in another project Pin
Dimitri Witkowski3-Jan-10 4:49
Dimitri Witkowski3-Jan-10 4:49 
QuestionRe: sending Form to User Control that has written in another project Pin
jojoba20103-Jan-10 22:28
jojoba20103-Jan-10 22:28 
AnswerRe: sending Form to User Control that has written in another project Pin
Dimitri Witkowski3-Jan-10 22:31
Dimitri Witkowski3-Jan-10 22:31 
QuestionOpenGL in C# and Visual Studio 2005/2008 Pin
Patrick Skelton3-Jan-10 4:34
Patrick Skelton3-Jan-10 4:34 
AnswerRe: OpenGL in C# and Visual Studio 2005/2008 Pin
harold aptroot3-Jan-10 4:47
harold aptroot3-Jan-10 4:47 
GeneralRe: OpenGL in C# and Visual Studio 2005/2008 Pin
Patrick Skelton3-Jan-10 4:59
Patrick Skelton3-Jan-10 4:59 
GeneralRe: OpenGL in C# and Visual Studio 2005/2008 Pin
harold aptroot3-Jan-10 5:55
harold aptroot3-Jan-10 5:55 
AnswerRe: OpenGL in C# and Visual Studio 2005/2008 Pin
Patrick Skelton3-Jan-10 6:16
Patrick Skelton3-Jan-10 6:16 
GeneralRe: OpenGL in C# and Visual Studio 2005/2008 Pin
harold aptroot3-Jan-10 6:25
harold aptroot3-Jan-10 6:25 
AnswerRe: OpenGL in C# and Visual Studio 2005/2008 Pin
Pete O'Hanlon3-Jan-10 9:32
mvePete O'Hanlon3-Jan-10 9:32 
AnswerRe: OpenGL in C# and Visual Studio 2005/2008 Pin
Patrick Skelton3-Jan-10 22:31
Patrick Skelton3-Jan-10 22:31 
QuestionEvent Handler Pin
AlexB473-Jan-10 0:06
AlexB473-Jan-10 0:06 
AnswerRe: Event Handler Pin
DaveyM693-Jan-10 0:33
professionalDaveyM693-Jan-10 0:33 
GeneralRe: Event Handler Pin
AlexB473-Jan-10 4:05
AlexB473-Jan-10 4:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.