本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFileStream.BeginRead方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFileStream.BeginRead方法的具体用法?C# IsolatedStorageFileStream.BeginRead怎么用?C# IsolatedStorageFileStream.BeginRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.IsolatedStorage.IsolatedStorageFileStream
的用法示例。
在下文中一共展示了IsolatedStorageFileStream.BeginRead方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsyncEndRead_Disposed
public void AsyncEndRead_Disposed ()
{
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("moon", FileMode.Create, isf)) {
byte [] data = new byte [2];
KeyValuePair<IsolatedStorageFile, IsolatedStorageFileStream> kvp = new KeyValuePair<IsolatedStorageFile, IsolatedStorageFileStream> (isf, fs);
IAsyncResult result = fs.BeginRead (data, 0, 2, new AsyncCallback (EndReadDisposed), kvp);
result.AsyncWaitHandle.WaitOne ();
}
}
示例2: AsyncRead
public void AsyncRead ()
{
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("moon", FileMode.Create, isf)) {
byte [] data = new byte [2];
IAsyncResult result = fs.BeginRead (data, 0, 2, new AsyncCallback (EndRead), fs);
result.AsyncWaitHandle.WaitOne ();
isf.Remove (); // this removed everything
Assert.Throws (delegate { fs.BeginRead (data, 0, 2, new AsyncCallback (EndRead), fs); }, typeof (IsolatedStorageException), "Remove/Write"); // Fails in Silverlight 3
isf.Dispose ();
Assert.Throws (delegate { fs.BeginRead (data, 0, 2, new AsyncCallback (EndRead), fs); }, typeof (ObjectDisposedException), "Dispose/Write");
}
isf = IsolatedStorageFile.GetUserStoreForApplication ();
Assert.AreEqual (0, isf.GetFileNames ().Length, "Empty");
}
示例3: AsyncEndRead_Removed
public void AsyncEndRead_Removed ()
{
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("moon", FileMode.Create, isf)) {
byte [] data = new byte [2];
KeyValuePair<IsolatedStorageFile, IsolatedStorageFileStream> kvp = new KeyValuePair<IsolatedStorageFile, IsolatedStorageFileStream> (isf, fs);
IAsyncResult result = fs.BeginRead (data, 0, 2, new AsyncCallback (EndReadRemoved), kvp);
result.AsyncWaitHandle.WaitOne ();
}
isf = IsolatedStorageFile.GetUserStoreForApplication ();
Assert.AreEqual (0, isf.GetFileNames ().Length, "Empty");
}
示例4: AsyncRead
public void AsyncRead ()
{
IsolatedStorageFileStream isfs = new IsolatedStorageFileStream ("cas-AsyncRead", FileMode.Create);
message = "AsyncRead";
reset.Reset ();
IAsyncResult r = isfs.BeginRead (new byte[0], 0, 0, new AsyncCallback (ReadCallback), isfs);
Assert.IsNotNull (r, "IAsyncResult");
if (!reset.WaitOne (timeout, true))
Assert.Ignore ("Timeout");
Assert.IsNull (message, message);
isfs.Close ();
}