示例#1
0
文件: AskUser.cs 项目: neiz/ravendb
		public static Task<string> QuestionAsync(string title, string question)
		{
			var dataContext = new InputModel
			{
				Title = title,
				Question = question
			};
			var inputWindow = new InputWindow
			{
				DataContext = dataContext
			};

			var tcs = new TaskCompletionSource<string>();

			inputWindow.Closed += (sender, args) =>
			{
				if (inputWindow.DialogResult == true)
					tcs.SetResult(dataContext.Answer);
				else
					tcs.SetCanceled();
			};

			inputWindow.Show();

			return tcs.Task;
		}
示例#2
0
        public static Task <string> QuestionAsync(string title, string question)
        {
            var dataContext = new InputModel
            {
                Title    = title,
                Question = question
            };

            var inputWindow = new InputWindow
            {
                DataContext = dataContext
            };

            var tcs = new TaskCompletionSource <string>();

            inputWindow.Closed += (sender, args) =>
            {
                if (inputWindow.DialogResult == true)
                {
                    tcs.SetResult(dataContext.Answer);
                }
                else
                {
                    tcs.SetCanceled();
                }
            };

            inputWindow.Show();

            return(tcs.Task);
        }