private IAsyncResult OpenContainer(string displayName, AsyncCallback callback, object state)
 {
     try {
         OpenContainerAsynchronous AsynchronousOpen = new OpenContainerAsynchronous(Open);
         return(AsynchronousOpen.BeginInvoke(displayName, callback, state));
     } finally {
     }
 }
Exemple #2
0
 /// <summary>
 /// Begins the open for a StorageContainer.
 /// </summary>
 /// <returns>The open StorageContainer.</returns>
 /// <param name="displayName">Name of file.</param>
 /// <param name="callback">Method to call on completion.</param>
 /// <param name="state">Request identifier object for callback (can be null).</param>
 public IAsyncResult BeginOpenContainer(
     string displayName,
     AsyncCallback callback,
     object state
     )
 {
     try
     {
         OpenContainerAsynchronous AsynchronousOpen = new OpenContainerAsynchronous(Open);
         return(AsynchronousOpen.BeginInvoke(displayName, callback, state));
     }
     finally
     {
         // TODO:  No resources to clean up?  Remove this finally block?
     }
 }
Exemple #3
0
        private IAsyncResult OpenContainer(string displayName, AsyncCallback callback, object state)
        {
#if !WINDOWS_PHONE81 && !ANDROID && !IOS && !NETFX_CORE && !WINDOWS_PHONE
            try
            {
                OpenContainerAsynchronous AsynchronousOpen = new OpenContainerAsynchronous(Open);
#if WINRT
                containerDelegate = AsynchronousOpen;
#endif
                return(AsynchronousOpen.BeginInvoke(displayName, callback, state));
            }
            finally
            {
            }
#else
            var tcs  = new TaskCompletionSource <StorageContainer>(state);
            var task = Task.Run <StorageContainer>(() => Open(displayName));
            task.ContinueWith(t =>
            {
                // Copy the task result into the returned task.
                if (t.IsFaulted)
                {
                    tcs.TrySetException(t.Exception.InnerExceptions);
                }
                else if (t.IsCanceled)
                {
                    tcs.TrySetCanceled();
                }
                else
                {
                    tcs.TrySetResult(t.Result);
                }

                // Invoke the user callback if necessary.
                if (callback != null)
                {
                    callback(tcs.Task);
                }
            });
            return(tcs.Task);
#endif
        }
Exemple #4
0
		private IAsyncResult OpenContainer (string displayName, AsyncCallback callback, object state)
		{
			try {
				OpenContainerAsynchronous AsynchronousOpen = new OpenContainerAsynchronous (Open);
#if WINRT
                containerDelegate = AsynchronousOpen;
#endif
                return AsynchronousOpen.BeginInvoke (displayName, callback, state);
			} finally {
			}
		}
Exemple #5
0
		/// <summary>
		/// Begins the open for a StorageContainer.
		/// </summary>
		/// <returns>The open StorageContainer.</returns>
		/// <param name="displayName">Name of file.</param>
		/// <param name="callback">Method to call on completion.</param>
		/// <param name="state">Request identifier object for callback (can be null).</param>
		public IAsyncResult BeginOpenContainer(
			string displayName,
			AsyncCallback callback,
			object state
		) {
			try
			{
				OpenContainerAsynchronous AsynchronousOpen = new OpenContainerAsynchronous(Open);
				return AsynchronousOpen.BeginInvoke(displayName, callback, state);
			}
			finally
			{
				// TODO:  No resources to clean up?  Remove this finally block?
			}
		}
Exemple #6
0
		private IAsyncResult OpenContainer (string displayName, AsyncCallback callback, object state)
        {

#if !WINDOWS_PHONE81 && !ANDROID && !IOS && !NETFX_CORE && !WINDOWS_PHONE
            try
            {
                OpenContainerAsynchronous AsynchronousOpen = new OpenContainerAsynchronous(Open);
#if WINRT
                containerDelegate = AsynchronousOpen;
#endif
                return AsynchronousOpen.BeginInvoke(displayName, callback, state);
            }
            finally
            {
            }
#else
            var tcs = new TaskCompletionSource<StorageContainer>(state);
            var task = Task.Run<StorageContainer>(() => Open(displayName));
            task.ContinueWith(t =>
            {
                // Copy the task result into the returned task.
                if (t.IsFaulted)
                    tcs.TrySetException(t.Exception.InnerExceptions);
                else if (t.IsCanceled)
                    tcs.TrySetCanceled();
                else
                    tcs.TrySetResult(t.Result);

                // Invoke the user callback if necessary.
                if (callback != null)
                    callback(tcs.Task);
            });
            return tcs.Task;
#endif
        }