is it possible to create properties with async get and set methods?
if yes, how?
if no, how should I call async methods in get and set properly?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. From section 10.15 of the C# 5 spec:
So it’s only methods, lambda expressions and anonymous methods that can use the
asyncmodifier.Personally I’d think it somewhat odd to have a property like that anyway, especially as the property would have had to return
Task<T>rather thanT. A property should usually “feel” pretty lightweight – which doesn’t really fit in with async.