Click here to Skip to main content
15,399,959 members
Home / Discussions / C#
   

C#

 
AnswerRe: gfhfgh Pin
Wes Aday9-Oct-12 5:06
professionalWes Aday9-Oct-12 5:06 
AnswerRe: gfhfgh Pin
Dave Kreskowiak9-Oct-12 6:00
mveDave Kreskowiak9-Oct-12 6:00 
JokeRe: gfhfgh Pin
Paul Conrad10-Oct-12 7:41
professionalPaul Conrad10-Oct-12 7:41 
AnswerRe: gfhfgh Pin
Keith Barrow9-Oct-12 6:27
professionalKeith Barrow9-Oct-12 6:27 
GeneralRe: gfhfgh Pin
OriginalGriff9-Oct-12 21:08
mveOriginalGriff9-Oct-12 21:08 
QuestionHelp With Delegates Pin
WebMaster9-Oct-12 3:00
MemberWebMaster9-Oct-12 3:00 
AnswerRe: Help With Delegates Pin
n.podbielski9-Oct-12 3:53
Membern.podbielski9-Oct-12 3:53 
AnswerRe: Help With Delegates Pin
BobJanova9-Oct-12 3:53
MemberBobJanova9-Oct-12 3:53 
You're thinking of delegates and events backwards. If you want LocalSource to call delegates in listeners, then it should publish an event, and listeners should hook onto it, i.e.

class LocalSource {
 public event NewFrameDelegate NewFrame;
 
 // ...

 private void MoveToNewFrame(){
  Bitmap bitmap = SomeMethodToMakeFrameImage();
  NewFrameDelegate newFrame = NewFrame;
  if(newFrame != null) newFrame(bitmap);
 }
}

class ViewingWindow : UserControl { // or whatever
 void SomeMethod() {
  LocalSource source = new LocalSource(this);
  source.NewFrame += bitmap => {
   // whatever
  };
 }
}


Alternatively, if you want the method to be called from the source, then you shouldn't be using a delegate at all, but an interface:

interface INewFrameListener {
 void NewFrame(Bitmap bitmap);
}

class LocalSource {
 // ...

 private void MoveToNewFrame(){
  Bitmap bitmap = SomeMethodToMakeFrameImage();
  INewFrameListener newFrameListener = ViewingWindow as INewFrameListener;
  if(newFrameListener != null) newFrameListener.NewFrame(bitmap);
 }
}

class ViewingWindow : UserControl, INewFrameListener {
 void NewFrame(Bitmap bitmap) {
  // whatever
 }
}

AnswerRe: Help With Delegates Pin
Stefano Manni10-Oct-12 0:00
MemberStefano Manni10-Oct-12 0:00 
Questionhow to use subtract operation in windows form applicaion Pin
sri apple9-Oct-12 1:58
Membersri apple9-Oct-12 1:58 
AnswerRe: how to use subtract operation in windows form applicaion Pin
Pete O'Hanlon9-Oct-12 2:10
mvaPete O'Hanlon9-Oct-12 2:10 
GeneralRe: how to use subtract operation in windows form applicaion Pin
Eddy Vluggen9-Oct-12 2:47
professionalEddy Vluggen9-Oct-12 2:47 
GeneralRe: how to use subtract operation in windows form applicaion Pin
Pete O'Hanlon9-Oct-12 3:06
mvaPete O'Hanlon9-Oct-12 3:06 
GeneralRe: how to use subtract operation in windows form applicaion Pin
Shameel9-Oct-12 4:56
professionalShameel9-Oct-12 4:56 
AnswerRe: how to use subtract operation in windows form applicaion Pin
Eddy Vluggen9-Oct-12 2:46
professionalEddy Vluggen9-Oct-12 2:46 
AnswerRe: how to use subtract operation in windows form applicaion Pin
KiranKumar Roy14-Oct-12 1:47
MemberKiranKumar Roy14-Oct-12 1:47 
QuestionDatacache Pin
nitin_ion9-Oct-12 0:25
Membernitin_ion9-Oct-12 0:25 
AnswerRe: Datacache Pin
Pete O'Hanlon9-Oct-12 0:40
mvaPete O'Hanlon9-Oct-12 0:40 
GeneralRe: Datacache Pin
nitin_ion9-Oct-12 17:15
Membernitin_ion9-Oct-12 17:15 
GeneralRe: Datacache Pin
Pete O'Hanlon9-Oct-12 20:18
mvaPete O'Hanlon9-Oct-12 20:18 
GeneralRe: Datacache Pin
Pete O'Hanlon9-Oct-12 22:01
mvaPete O'Hanlon9-Oct-12 22:01 
GeneralRe: Datacache Pin
nitin_ion9-Oct-12 23:15
Membernitin_ion9-Oct-12 23:15 
GeneralRe: Datacache Pin
Pete O'Hanlon9-Oct-12 23:58
mvaPete O'Hanlon9-Oct-12 23:58 
QuestionGenereate XML file from sql in C# Pin
Md. Rayhan Kabir8-Oct-12 18:17
MemberMd. Rayhan Kabir8-Oct-12 18:17 
AnswerRe: Genereate XML file from sql in C# Pin
Sarath C8-Oct-12 22:42
MemberSarath C8-Oct-12 22:42 

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.