質問

私は試しています:

request = WebRequest.Create( uri )
responseTask = request.GetResponseAsync
action = Action.new { process_request( sender, e ) }
task = Task.new( action )
responseTask.Wait( TimeSpan.new( -1 ) )
responseTask.ContinueWith( task )
.

しかし以下のエラーがある:

can't convert System::Threading::Tasks::Task into System::Action[System::Threading::Tasks::Task] (TypeError)  
.

upd

responseTask = request.GetResponseAsync  
action = Action[Task].new { process_request( sender, e ) }  
responseTask.Wait( TimeSpan.new( -1 ) )  
responseTask.ContinueWith( action )  
.

私はこのエラーを得ています:

Found multiple methods for 'ContinueWith': ContinueWith(System::Action[System::Threading::Tasks::Task]), ContinueWith(System::Action[System::Threading::Tasks::Task[System::Net::WebResponse]]) (System::Reflection::AmbiguousMatchException)
.

役に立ちましたか?

解決

連続WITH

Action<Task> 
.

、その他のオーバーロードがありますが、タスクではありません。

例えば:

action = Action.new {Console.WriteLine("action")}
task = Task.new( action )
action2 = Action[Task].new{Console.WriteLine("action2")}
task.ContinueWith(action2)
task.Start()
#prints "action" then "action2".
.


IronRubyでは、一般的なタスクである一般的なタイプの専門化をスキップさせることができます。

 action = Action[Task[WebResponse]].new { process_request( sender, e ) }
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top