Example #1
0
        //再生終了時にイベントを発砲する
        //protected virtualにする意味は特にないが継承先で処理を挟みたい時 等のために
        //こういった形にしておくのが暗黙のルールっぽい??
        protected virtual void OnPlayingCompleted(EventArgs e)
        {
            //(?.で購読者がいなければ何もしないし
            //  複数いたらそれぞれ登録されたメソッドを(object sender, EventArgs e)の形で呼び出す)
            //senderはこのPlayer自身 eはsequencer.PlayingCompletedの引数そのまま(実際PlayingCompletedのeは空だが)
            //通常は↓でいいが
            //PlayingCompleted?.Invoke(this, e);
            //このメソッドを呼ぶSequencer_PlayingCompleted()がsequencerのスレッドで呼ばれるため
            //この場所はUIスレッドではないのでUIスレッドで呼んでもらう(テンプレ)
            Application.Current.Dispatcher.Invoke(new Action(() => PlayingCompleted?.Invoke(this, e)));


            var id = System.Threading.Thread.CurrentThread.ManagedThreadId;

            Console.WriteLine($"OnPlayingCompleted ここはUIスレッドでない!! ThreadID : {id}");
        }
Example #2
0
 protected virtual void OnPlayingCompleted(EventArgs e)
 {
     PlayingCompleted?.Invoke(this, e);
 }