From 483ff2b93f935b38ca33ab9bee8e6ccbc1776876 Mon Sep 17 00:00:00 2001 From: jta Date: Thu, 9 Jun 2022 15:12:32 -0400 Subject: [PATCH] wip: add callback method to readDataFromFile method --- .../PepperDashEssentialsBase/File/FileIO.cs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs index f92a46fe..55eaf844 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs @@ -6,6 +6,8 @@ using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronIO; using PepperDash.Core; using Crestron.SimplSharpPro.CrestronThread; +using Crestron.SimplSharp.Net.Http; +using Crestron.SimplSharp.CrestronIO; namespace PepperDash.Essentials.Core { @@ -124,11 +126,11 @@ namespace PepperDash.Essentials.Core } - public static void ReadDataFromFileASync(string fileName) + public static void ReadDataFromFileASync(string fileName, GotFileEventHandler callback) { try { - ReadDataFromFileASync(GetFile(fileName)); + ReadDataFromFileASync(GetFile(fileName), callback); } catch (Exception e) { @@ -136,11 +138,13 @@ namespace PepperDash.Essentials.Core } } - public static void ReadDataFromFileASync(FileInfo file) + + + public static void ReadDataFromFileASync(FileInfo file, GotFileEventHandler callback) { try { - CrestronInvoke.BeginInvoke(o => _ReadDataFromFileASync(file)); + CrestronInvoke.BeginInvoke((o => _ReadDataFromFileASync(file, callback))); } catch (Exception e) { @@ -148,7 +152,7 @@ namespace PepperDash.Essentials.Core } } - private static void _ReadDataFromFileASync(FileInfo file) + private static void _ReadDataFromFileASync(FileInfo file, GotFileEventHandler callback) { string data; try @@ -171,7 +175,8 @@ namespace PepperDash.Essentials.Core Debug.Console(2, "File {0} Does not exsist", file.FullName); data = ""; } - GotFileEvent.Invoke(null, new FileEventArgs(data)); + callback.Invoke(null, new FileEventArgs(data)); + //callback.Invoke(null, new FileEventArgs(data)); } else { @@ -313,5 +318,9 @@ namespace PepperDash.Essentials.Core public FileEventArgs(string data) { Data = data; } public string Data { get; private set; } // readonly + } + public enum ReadFileDispatchError + { + } } \ No newline at end of file