private void WebReadCallback(IAsyncResult asyncResult) { try { WebReadState webReadState = (WebReadState)asyncResult.AsyncState; int count = webReadState.readStream.EndRead(asyncResult); if (count > 0) { webReadState.memoryStream.Write(webReadState.buffer, 0, count); try { webReadState.readStream.BeginRead(webReadState.buffer, 0, webReadState.buffer.Length, new AsyncCallback(WebReadCallback), webReadState); } catch (WebException exp) { this.Dispatcher.Invoke(DispatcherPriority.Render, new WebRequestErrorDelegate(WebRequestError), exp); } } else { this.Dispatcher.Invoke(DispatcherPriority.Render, new WebRequestFinishedDelegate(WebRequestFinished), webReadState.memoryStream); } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "WebReadCallBack()", "Controls\\VMuktiGrid\\ImageAnim.cs"); } }
private void WebResponseCallback(IAsyncResult asyncResult) { try { WebReadState webReadState = (WebReadState)asyncResult.AsyncState; WebResponse webResponse; try { webResponse = webReadState.webRequest.EndGetResponse(asyncResult); webReadState.readStream = webResponse.GetResponseStream(); webReadState.buffer = new byte[100000]; webReadState.readStream.BeginRead(webReadState.buffer, 0, webReadState.buffer.Length, new AsyncCallback(WebReadCallback), webReadState); } catch (WebException exp) { this.Dispatcher.Invoke(DispatcherPriority.Render, new WebRequestErrorDelegate(WebRequestError), exp); } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "WebResponseCallBack()", "Controls\\VMuktiGrid\\ImageAnim.cs"); } }
private void GetGifStreamFromHttp(Uri uri) { try { try { WebReadState webReadState = new WebReadState(); webReadState.memoryStream = new MemoryStream(); webReadState.webRequest = WebRequest.Create(uri); webReadState.webRequest.Timeout = 10000; webReadState.webRequest.BeginGetResponse(new AsyncCallback(WebResponseCallback), webReadState); } catch (SecurityException) { // Try image load, The Image class can display images from other web sites CreateNonGifAnimationImage(); } } catch (Exception ex) { VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "GetGifStreamFromHttp()", "Controls\\VMuktiGrid\\ImageAnim.cs"); } }