c# - Proper way to filter BlockBuffer.RecieveAsync -


good day.

i have tpl dataflow mesh rpc calls

it has 2 unkinked flows in simplified way looks this:

output flow:

  • blockbuffer store output
  • actionblock send output server , produce sent id

and input flow:

  • while loop recieve data
  • transformblock parse data
  • blockbuffer save answer sentid

there problem: when make calls separate threads can mess answers, need filter it.

my rpc call:

public async task<rpcanswer> performrpccall(call rpccall) {     ...     _outputrpccalls.post(rpccall);     long uniqueid = getuniq(); // call unique id     ...     var sent = new tuple<long, long>(uniqueid, 0);     while (_sentrpccalls.tryreceive(u => u.item1 == uniqueid, out sent)) ; // generated id send function      return await _inputanswers.receiveasync(timespan.fromseconds(30)); } 

as can see have uniqueid can me determine answer call, but how can filter , await it?

is way have array of buffers (writeonceblock maybe?) created in rpc call , linkedto filter?

ok, didn't found proper way made dirty workaround

while (true) {     answer = await _inputanswers.receiveasync(timespan.fromseconds(5));       if (answer.success)     {         if (answer.answer.combinator.valuetype.equals(rpccall.combinator.valuetype))         {             break;         }         else         {             // wrong answer - post             _inputanswers.post(answer.answer);         }      }     else     {         // answer fail - return         break;     } } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -