From 9369967c7ffca456e3ac286df3ad8efafe263f95 Mon Sep 17 00:00:00 2001 From: amaitland Date: Thu, 29 May 2014 13:03:55 +1000 Subject: [PATCH] Add GetText() sync method --- CefSharp.WinForms/WebView.cs | 9 +++++++++ CefSharp.Wpf/WebView.cs | 9 +++++++++ CefSharp/IWebBrowser.cs | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/CefSharp.WinForms/WebView.cs b/CefSharp.WinForms/WebView.cs index 40e3957ae..d85bb7184 100644 --- a/CefSharp.WinForms/WebView.cs +++ b/CefSharp.WinForms/WebView.cs @@ -322,5 +322,14 @@ namespace CefSharp.WinForms managedCefBrowserAdapter.GetText(taskStringVisitor); return taskStringVisitor.Task; } + + public string GetText() + { + var task = GetTextAsync(); + + task.Wait(); + + return task.Result; + } } } diff --git a/CefSharp.Wpf/WebView.cs b/CefSharp.Wpf/WebView.cs index 20287cb54..0ddf3112b 100644 --- a/CefSharp.Wpf/WebView.cs +++ b/CefSharp.Wpf/WebView.cs @@ -1127,5 +1127,14 @@ namespace CefSharp.Wpf managedCefBrowserAdapter.GetText(taskStringVisitor); return taskStringVisitor.Task; } + + public string GetText() + { + var task = GetTextAsync(); + + task.Wait(); + + return task.Result; + } } } diff --git a/CefSharp/IWebBrowser.cs b/CefSharp/IWebBrowser.cs index 1088e9f7b..8e6e9da97 100644 --- a/CefSharp/IWebBrowser.cs +++ b/CefSharp/IWebBrowser.cs @@ -146,5 +146,11 @@ namespace CefSharp /// /// that when executed returns the frame display text as a string. Task GetTextAsync(); + + /// + /// Retrieve the main frame's display text. + /// + /// The main frame display text as a string. + string GetText(); } }