c# - Ref in async Task -


how can pass reference parameter async method in windows store app ?
i'm looking this:

var = dothis(ref obj.value);  public async task dothis(ref int value) {     value = 10; } 

but error:

async methods cannot have ref or out parameters

has way?

note:
i need pass obj.value. method used different types of objects, same type of objects, 1 object, pass obj.val_1, obj.val_2 or obj.val_10. values same type (for ex string)

if don't care little overhead , possibly prolonged lifetime of objects, emulate ref behavior passing setter , getter method function, this:

public async task dostuff(func<int> getter, action<int> setter) {     var value1 = getter();     await dosomeotherasyncstuff();     setter(value1 * value1); } 

and call this:

await dostuff(() => obj.value, x => obj.value = x); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -