이 작업을 시도하고 있지만 작동하지 않습니다. 몇 가지 제안?C# lambda ref out
int test_i = 0;
DoSomethingThatTakesAgesAndNeedsToUpdateUiWhenFinished(test_i);
test_i <- still is 0 and not 3!!!
public void DoSomethingThatTakesAgesAndNeedsToUpdateUiWhenFinished(int i)
{
DisableUi();
m_commandExecutor.ExecuteWithContinuation(
() =>
{
// this is the long-running bit
ConnectToServer();
i = 3; <--------------------------
// This is the continuation that will be run
// on the UI thread
return() =>
{
EnableUi();
};
});
}
왜 내가 test_i를 3으로 설정할 수 없습니까? 나는 또한 심판을 밖으로 시도했지만 작동하지 않습니다.
문제를 해결하려면 어떻게해야합니까?
편집
이 시도하지만,이 방법은 데이터 세트의 ouside 여전히 비어했습니다.
public static void Select(DataGridView dataGridView, ref DataSet dataSet, params object[] parameters)
{
var _dataSet = dataSet;
AsyncCommandExecutor commandExecutor = new AsyncCommandExecutor(System.Threading.SynchronizationContext.Current);
commandExecutor.ExecuteWithContinuation(
() =>
{
// this is the long-running bit
_dataSet = getDataFromDb(parameters);
// This is the continuation that will be run on the UI thread
return() =>
{
dataGridView.DataSource = _dataSet.Tables[0].DefaultView;
};
});
dataSet = _dataSet;
}
답을 업데이트했습니다. 희망이 도움이 : O) –