mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
wip: add callback method to readDataFromFile method
This commit is contained in:
@@ -6,6 +6,8 @@ using Crestron.SimplSharp;
|
|||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using Crestron.SimplSharpPro.CrestronThread;
|
using Crestron.SimplSharpPro.CrestronThread;
|
||||||
|
using Crestron.SimplSharp.Net.Http;
|
||||||
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
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
|
try
|
||||||
{
|
{
|
||||||
ReadDataFromFileASync(GetFile(fileName));
|
ReadDataFromFileASync(GetFile(fileName), callback);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
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
|
try
|
||||||
{
|
{
|
||||||
CrestronInvoke.BeginInvoke(o => _ReadDataFromFileASync(file));
|
CrestronInvoke.BeginInvoke((o => _ReadDataFromFileASync(file, callback)));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
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;
|
string data;
|
||||||
try
|
try
|
||||||
@@ -171,7 +175,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
Debug.Console(2, "File {0} Does not exsist", file.FullName);
|
Debug.Console(2, "File {0} Does not exsist", file.FullName);
|
||||||
data = "";
|
data = "";
|
||||||
}
|
}
|
||||||
GotFileEvent.Invoke(null, new FileEventArgs(data));
|
callback.Invoke(null, new FileEventArgs(data));
|
||||||
|
//callback.Invoke(null, new FileEventArgs(data));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -313,5 +318,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
public FileEventArgs(string data) { Data = data; }
|
public FileEventArgs(string data) { Data = data; }
|
||||||
public string Data { get; private set; } // readonly
|
public string Data { get; private set; } // readonly
|
||||||
|
|
||||||
|
}
|
||||||
|
public enum ReadFileDispatchError
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user