protected virtual void OnVideoEncoded(Video video) { //VideoEncoded?.Invoke(this, EventArgs.Empty); // VideoEncoded? kontrolü subscrible olup olmadığını kontror eder. VideoEncoded?.Invoke(this, new VideoEventArgs { Video = video }); }
protected virtual void OnVideoEncoded(Video video) { VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); }
protected virtual void OnVideoEncoded(Video video) //event publisher method { VideoEncoded?.Invoke(this, new VideoEventArgs() { video = video }); }
protected virtual void VideoEncodingCompleted(Video _video) { //wait till the implemenation is done VideoEncoded?.Invoke(this, new VideoEncodedEventArgs() { MyVideo = _video }); }
protected virtual void OnVideoEncoded(Video video) { // sprawdĹşmy czy ktoĹ› subskrybuje event! VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); // source + dodatkowe argumenty }
//to raise an event we need to create a method that is responsible for it protected virtual void OnVideoEncoded(Video video) { //job of this method would be to notify all the subscribers // if there are subs, then VideoEncoded will not be null VideoEncoded?.Invoke(this, new VideoEventArgs { video = video }); }
protected virtual void OnVideoEncoded(Video video) { //if (VideoEncoded != null) same as this VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); }
protected virtual void OnVideoEncoded(Video video) { //VideoEncoded?.Invoke(this, EventArgs.Empty); VideoEncoded?.Invoke(this, new VideoEventArgs { Video = video }); }
// convention eventpublisher - protected, virtual, void , name - On+NameOfAnEvent protected virtual void OnVideoEncoded(Video video) { // pointer to the method. VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); }
protected virtual void OnVideoEncoded(Video video) { VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); // if (VideoEncoded != null) VideoEncoded(this, new VideoEventArgs() {Video = video}); // above two lines are the same }
// 3 protected virtual void OnVideoEncoded(Video video) // 3- Raise the event { //if(VideoEncoded != null) // check if there are subscribers (event handlers) // VideoEncoded(this, EventArgs.Empty); // OR VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); }
protected virtual void OnVideoEncoded(Video video) { //if the list of subscribers is not empty (null) then notify the subscribers //VideoEncoded?.Invoke(this, EventArgs.Empty); VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); }
protected virtual void OnVideoCoded(Video video) { if (VideoEncoded != null) { VideoEncoded.Invoke(this, new VideoEventArgs() { Video = video }); } }
//step 3. Raise and Event, so this method is responsible to raise the event // as per the .net naming conventions the event handler method should be protected, virtual, void and should begin wiht On //protected virtual void OnVideoEncoded() protected virtual void OnVideoEncoded(Video video) { //if(VideoEncoded != null) VideoEncoded(this,EventArgs.Empty) --OldWay //VideoEncoded?.Invoke(this, EventArgs.Empty);//this means the current class is the source of publishing the event //Sending Custom Data VideoEncoded?.Invoke(this, new VideoEventArgs() { video = video }); // }
protected virtual void OnVideoEncoded(Video video) { /* * if (VideoEncoded != null) * VideoEncoded(this, EventArgs.Empty); */ VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); }
// 3- Raise the event protected virtual void OnVideoEncoded(Video video) { //if ( VideoEncoded != null ) // VideoEncoded(this, EventArgs.Empty); // Refactored into this VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); }
protected virtual void OnVideoEncoded(Video video) { VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); //same as following lines //if(VideoEncoded != null) //{ // VideoEncoded(this, VideoEventArgs.Empty); //} }
public void EncodeVideo(Video video) { Video encryptedVideo = new Video(); encryptedVideo.Artist = video.Title; encryptedVideo.Title = video.Artist; //Simulating the encoding Logic Video Thread.Sleep(3000); VideoEncoded?.Invoke(video); }
protected virtual void OnVideoEncoded(Video v) { // The old way //if (VideoEncoded != null) //{ // VideoEncoded(this, new VideoEventArgs() { video = v }); //} VideoEncoded?.Invoke(this, new VideoEventArgs() { video = v }); }
protected virtual void OnVideoEncoded(Video video) { //if (VideoEncoded != null) //{ // VideoEncoded(this, EventArgs.Empty); //} var vEvents = new VideoEventArgs { Clip = video }; VideoEncoded?.Invoke(this, vEvents); // see: http://bit.ly/2ujCs1F }
} // raising the event here protected virtual void OnVideoEncoded(Video video) // this method invoke the event { //if (VideoEncoded != null) // check to see if there are any subscribers to this event(VideoEncoded) // VideoEncoded(this,EventArgs.Empty); // if not null than call event //VideoEncoded?.Invoke(this, EventArgs.Empty); // videoEncoded behind the scnene is a list of pointers to diff methods VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); // reference to the video }
// 2 - On[what-happend?] public void OnVideoEncoded(Video video) { //VideoEventArgs { Video = video } // shortcut for: //VideoEventArgs v = new VideoEventArgs(); //v.Video = video; if (VideoEncoded != null) { VideoEncoded.Invoke(this, new VideoEventArgs { Video = video }); } }
protected virtual void OnVideoEncoded(Video video) { VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); // Same Code Below /* if (VideoEncoded != null) * { * VideoEncoded(this, EventArgs.Empty); * } */ }
// In .NET the convention is that events sould be: // Protected // Virtual // Void // And always append "On" + Name of event protected virtual void OnVideoEncoded(Video video) { // This way is just fine but it can be shortened by using the nullable char (?) /* * if (VideoEncoded != null) * { * VideoEncoded.Invoke(this, EventArgs.Empty); * } */ // Here we used the nullable keyword (?) VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); }
// This is the method that raises the event // Will notify all subscribers of this event protected virtual void OnVideoEncoded(Video video) { // the source of this event, or the publisher of this event, is // this class / object. So we pass "this" as the first argument // Exemplo abaixo usando EventArgs com invoke // VideoEncoded?.Invoke(this, EventArgs.Empty); // Exemplo abaixo usando EventArgs com um if // if (VideoEncoded != null) // VideoEncoded(this, EventArgs.Empty);, // Exemplo abaixo passando um objeto de Video como parametroa VideoEncoded?.Invoke(this, new VideoEventArgs() { Video = video }); }
protected virtual void OnVideoEncoded(string title) { VideoEncoded?.Invoke(this, EventArgs.Empty); }
/// <summary> /// 3- To raise an event, we need a method that is responsible for that /// Acc. to .NET convention, your event publisher methods should be protected, virtual and void (also it doesn't make any sense to keep this method in public interface) /// Naming convention => Start with On + Name of the event /// </summary> protected virtual void OnVideoEncoded() { // First check if there are any subscribers in this event VideoEncoded?.Invoke(this, EventArgs.Empty); //Short for if(VideoEncoded != null) { VideoEncoded(this, EventArgs.Empty) }
public virtual void OnVideoEncoded(IVideo video) { VideoEncoded?.Invoke(this, new VideoEventArgs { Video = video }); }
protected virtual void OnVideoEncoded(Video video) { VideoEncoded?.Invoke(video); }
private void OnVideoEncoded(RunDataEventArgs data) { VideoEncoded?.Invoke(this, data); }