Search code examples
c#.netccr

how can i pass a parameter to EnqueueTimer in the .net ccr


Unclear if there are ccr gurus here but let's try anyway.

I have this function in my code:

dq.EnqueueTimer(TimeSpan.FromMilliseconds(TIMEOUT), timeOutFn);

which will call my function after the timeout. However since I need this timer on a lot of open sockets, I would like to pass a parameter(or ID) to the timer function.

How do you do this?

Thanks

R


Solution

  • Something like this should do it.

    var timerPort = new Port<DateTime>();
    dq.EnqueueTimer(TimeSpan.FromMilliseconds(TIMEOUT), timerPort);
    timerPort.Receive(ignored => MyFunc(myParam));