Search code examples
oauthasync-awaitlinkedin-apiowinkatana

What do I return from the LinkedInAuthenticationProvider.OnAuthenticated delegate?


OnAuthenticated is a Func<LinkedInAuthenticationContext, Task> and is a member of the LinkedInAuthenticationProvider class. I do not want to return anything from it. I basically just want to subscribe to this delegate to print a few diagnostic details to the debug window.

How do I return a task that means nothing?


Solution

  • How do I return a task that means nothing

    Task.FromResult(true);
    

    Or:

    Task dummy = new Task(()=> {return;});
    dummy.Start();
    
    return dummy;
    

    EDIT:

    You can define a static class for that matter:

    public static class CompletedTask
    {
        private static readonly Task _completed = new Task(()=> {return;});
        static CompletedTask()
        {
            _completed.Start();
        }
    
        public static Task GetCompletedTask()
        {
            return _completed;
        }       
    }
    

    They did the same thing in project Orleans - TaskDone class.