Cannot implicity convert type void to System.Threading.Tasks.Task<bool>

Posted by sagesky36 on Stack Overflow See other posts from Stack Overflow or by sagesky36
Published on 2013-11-08T21:50:29Z Indexed on 2013/11/08 21:53 UTC
Read the original article Hit count: 270

Filed under:
|
|
|
|

I have a WCF Service that contains the following method. All the methods in the service are asynchrounous and compile just fine.

public async Task<Boolean> ValidateRegistrationAsync(String strUserName)
        {
            try
            {
                using (YeagerTechEntities DbContext = new YeagerTechEntities())
                {
                    DbContext.Configuration.ProxyCreationEnabled = false;
                    DbContext.Database.Connection.Open();

                    var reg = await DbContext.aspnet_Users.FirstOrDefaultAsync(f => f.UserName == strUserName);

                    if (reg != null)
                        return true;
                    else
                        return false;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }

My client application was set to access the WCF service with the check box for the "Allow generation of asynchronous operations" and it generated the proxy just fine.

I am receiving the above subject error when trying to call this WCF service method from my client with the following code. Mind you, I know what the error message means, but this is my first time trying to call an asynchronous task in a WCF service from a client.

Task<Boolean> blnMbrShip = db.ValidateRegistrationAsync(FormsAuthentication.Decrypt(cn.Value).Name);

What do I need to do to properly call the method so the design time compile error disappears?

Thanks so much in advance...

© Stack Overflow or respective owner

Related posts about c#

Related posts about multithreading