private static string userInput;
private static void Example() {
userInput = null;
GetUserInput(); // tells the UI to request user input on the UI thread
while (userInput == null) { // wait for user input
Thread.Sleep(100);
}
ProcessUserInput(userInput); // now use that input
}