Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2015-11-18 17:14:03 +0300
committerLluis Sanchez <lluis@xamarin.com>2015-11-25 18:44:59 +0300
commit74881948086cfe253d389d074d44d12f9149fc60 (patch)
treeffdb19809fdd73e84c4a3dc502126803e88d3904 /main/src/addins/MonoDevelop.HexEditor
parentd804ac2110c412f444528960a66f2e835a8ec88b (diff)
Asynchronize document load and save operations
Diffstat (limited to 'main/src/addins/MonoDevelop.HexEditor')
-rw-r--r--main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Buffer.cs11
-rw-r--r--main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs8
2 files changed, 16 insertions, 3 deletions
diff --git a/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Buffer.cs b/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Buffer.cs
index 4b5e64b651..31f8c29d7a 100644
--- a/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Buffer.cs
+++ b/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Buffer.cs
@@ -26,6 +26,7 @@
using System;
using System.IO;
+using System.Threading.Tasks;
namespace Mono.MHex.Data
{
@@ -81,6 +82,16 @@ namespace Mono.MHex.Data
return new ArrayBuffer (buf);
}
+ public static async Task<IBuffer> LoadAsync (Stream stream)
+ {
+ int count = (int) stream.Length;
+ byte[] buf = new byte[count];
+
+ await stream.ReadAsync (buf, 0, count);
+
+ return new ArrayBuffer (buf);
+ }
+
public static IBuffer Load (string fileName)
{
using (Stream stream = File.OpenRead (fileName)) {
diff --git a/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs b/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs
index e01cddac17..f23c5fc900 100644
--- a/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs
+++ b/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs
@@ -33,6 +33,7 @@ using MonoDevelop.Ide.Gui.Content;
using Xwt;
using MonoDevelop.Ide.Fonts;
using MonoDevelop.Ide.Editor;
+using System.Threading.Tasks;
namespace MonoDevelop.HexEditor
{
@@ -78,18 +79,19 @@ namespace MonoDevelop.HexEditor
hexEditor.Repaint ();
}
- public override void Save (FileSaveInformation fileSaveInformation)
+ public override Task Save (FileSaveInformation fileSaveInformation)
{
File.WriteAllBytes (fileSaveInformation.FileName, hexEditor.HexEditorData.Bytes);
ContentName = fileSaveInformation.FileName;
this.IsDirty = false;
+ return Task.FromResult (true);
}
- public override void Load (FileOpenInformation fileOpenInformation)
+ public override async Task Load (FileOpenInformation fileOpenInformation)
{
var fileName = fileOpenInformation.FileName;
using (Stream stream = File.OpenRead (fileName)) {
- hexEditor.HexEditorData.Buffer = ArrayBuffer.Load (stream);
+ hexEditor.HexEditorData.Buffer = await ArrayBuffer.LoadAsync (stream);
}
ContentName = fileName;