I have a method which fetches some values from Firebase as below:
void getTable(Action<IDictionary> callBack)
{
// function & data initialized here
function.CallAsync(data).ContinueWith((callTask) =>
{
if (callTask.IsFaulted)
callBack(null);
else if (callTask.IsCompleted)
{
Debug.Log("I am being executed when done");
var result = (IDictionary) callTask.Result.Data;
callBack(result);
}
});
}
I call this method from another method as like:
public void GetTable(ref string valueReturned)
{
string val = null;
getTable((dictionary =>
{
Debug.Log("Done getting values");
val = (string) dictionary["someValue"]; // returns "testValue" to val
}));
valueReturned = val;
Debug.Log("Value is:" + valueReturned);
Debug.Log("Completed Execution");
}
Expected Output:
- I am being executed when done
- Done getting values
- Value is: testValue
- Completed Execution
What output I am getting is:
- I am being executed when done
- Value is: (null)
- Completed Execution
- Done getting values
I tried to assign "valueReturned" within the lambda expression of GetTable method. But it gave error : "Cannot user ref parametre inside a lambda expression"