During WCF events called by web clients my WCF Server needs to Start a new asynchronous Task on each call but with a delay of more then a minute.
My current solution consists on Task.Factory.StartNew(() => DoTask()); where DoTask() calls await Task.Delay(XXX); before executing its code. This WCF event happens allot in our production environment which causes a creation of many threads that remain stuck for a whole minute.
One of the solutions I have thought of was to use Task.Delay(XXX).ContinueWith((i) => DoTask()); In this solution no threads are created until DoTask() begins to run but I see 2 task that are created for Task.Delay() call.
Which solution is better (or maybe neither...) Creating many threads or creating many Tasks? Thanks.