private static void DCTNameTest() { DCT.Execute(c => { }); DCT.Execute <string>(c => { return(""); }); DCT.ExecuteAsync(c => { }); DCT.ExecuteAsync <string>(c => { return(""); }, (c, result) => { }); DCT.ExecuteMainThread(c => { }); }
public static void UpdateObjectState(string text) { DCT.ExecuteMainThread(d => { if (ObjectStateCache != null) { ObjectStateCache(text); } }); }
public static void UpdateWorkState(string text) { DCT.ExecuteMainThread(d => { if (WorkStateCache != null) { WorkStateCache(text); } }); }
public static void UpdateActionState(string text) { DCT.ExecuteMainThread(d => { if (ActionStateCache != null) { ActionStateCache(text); } }); }
/// <summary> /// Вызывать только внутри DownloadPage /// </summary> /// <param name="url"></param> public static void NavigatePage(string url) { if (string.IsNullOrWhiteSpace(url)) { throw new NullReferenceException("DownloadPage url can't be null!"); } DCT.ExecuteMainThread((d) => { WebBrowser.Navigate(url); Wait(); }, isAsync: false); }
public static void WaitPage(Action <string> afterCompleted) { Execute(() => { Stream stream = null; DCT.ExecuteMainThread(d => { Wait(); stream = WebBrowser.DocumentStream; }, isAsync: false); var result = ""; using (var sr = new StreamReader(stream)) result = sr.ReadToEnd(); afterCompleted?.Invoke(result); }); }
public static void DownloadPage(string url, Action <string> compliteAction) { if (string.IsNullOrWhiteSpace(url)) { throw new NullReferenceException("DownloadPage url can't be null!"); } Execute(() => { Stream stream = null; DCT.ExecuteMainThread(d => { WebBrowser.Navigate(url); Wait(); stream = WebBrowser.DocumentStream; }, isAsync: false); var result = ""; using (var sr = new StreamReader(stream)) result = sr.ReadToEnd(); compliteAction?.Invoke(result); }); }
void AddImage() { DCT.ExecuteMainThread(d => { var openFile = new Microsoft.Win32.OpenFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop), FilterIndex = 2, RestoreDirectory = true }; if (openFile.ShowDialog() == true) { using (var client = new ImageService()) { var r = client.Ping(); Console.WriteLine($"Ping = {r}"); var bitmap = new BitmapImage(new Uri(openFile.FileName)); var bytes = ImageHelper.ConvertImageToByte(bitmap); client.AddImage(AddImageCallback, System.IO.Path.GetFileNameWithoutExtension(openFile.SafeFileName), bytes); } } }); }