2011-09-14 2 views
2

그래서 모든 선수가 지금처럼 타이머가있는 게임 서버가 있습니다ConnectableObservable 등록 된 모든 메소드를 한 번에 삭제 하시겠습니까?

this.player.Timer = from tick in TimerPublisher where tick % 1 == 0 select tick; 

을 그리고 난 같은 몇 가지 가입 방법이 있습니다

this.player.Timer.Subscribe(tick => IncreseStamina()); 
this.player.Timer.Subscribe(tick => IncresePower()); 
//etc 

그래서 내가 뭘 원하는 것은 대신

을 설정하는이다
IDisposable dis = //the subscribed method; 

그래서 내가 말할 수있는

dis.Dispose(); //so it Dispose that method 
,

나는 내 구독 방식을 모두 폐기 할 수 있습니까?

+0

타이머는 어떤 유형의 개체입니까? 그것은 일종의 열거 형 속성/컬렉션입니까? –

답변

1

이 시도 :

IDisposable dis = new CompositeDisposable(new [] 
{ 
    this.player.Timer.Subscribe(tick => IncreseStamina()), 
    this.player.Timer.Subscribe(tick => IncresePower()), 
    //etc 
}); 

이 그럼 당신은 쓸 수 있습니다 :

dis.Dispose(); 

쉬운, 응?

관련 문제