BlipFace.Service.Communication.BlipCommunication.AfterStatusesUpdatedSince C# (CSharp) Метод

AfterStatusesUpdatedSince() приватный Метод

Wywoływana jako callback po metodzie GetUserDashboardSince
private AfterStatusesUpdatedSince ( IAsyncResult result ) : void
result IAsyncResult
Результат void
        private void AfterStatusesUpdatedSince(IAsyncResult result)
        {
            //pobieramy obiekt HttpClient, dzięki któremu został wysłany request
            //przekazaliśmy ten obiekt jako state
            var client = result.AsyncState as HttpClient;

            //pobieramy odpowiedź
            HttpResponseMessage resp = null;
            StatusesList statuses = null;
            BlipCommunicationState state = BlipCommunicationState.OK;
            Exception exp = null;
            HttpStatusCode httpCode = HttpStatusCode.OK;

            try
            {
                lock (httpAsyncClientLock)
                {
                    resp = client.EndSend(result);
                }

                resp.EnsureStatusIsSuccessful();

                //deserializujemy z json

                //todo: do usunięcia testowo opóźniam przetworzenie żadania
                //Thread.Sleep(10*1000);

                if (resp.Content.GetLength() > 2)
                {
                    statuses = resp.Content.ReadAsJsonDataContract<StatusesList>();
                }
            }
            catch (HttpStageProcessingException stageEx)
            {
                state = BlipCommunicationState.CommunicationError;
                if (resp != null)
                {
                    httpCode = resp.StatusCode;
                }
            }
            catch (ArgumentOutOfRangeException aorEx)
            {
                state = BlipCommunicationState.CommunicationError;
                if (resp != null)
                    httpCode = resp.StatusCode;
                //gdy wystąpiły jakieś błędy w komunikacji
            }
            catch (SerializationException serEx)
            {
                state = BlipCommunicationState.CommunicationError | BlipCommunicationState.Error;
                httpCode = resp.StatusCode;
                exp = serEx;
            }
            catch (Exception ex)
            {
                state = BlipCommunicationState.Error;
                exp = ex;
            }
            finally
            {
                if (resp != null)
                {
                    resp.Dispose();
                    resp = null;
                }
            }

            if (((state & BlipCommunicationState.CommunicationError) == BlipCommunicationState.CommunicationError)
                && CommunicationError != null)
            {
                CommunicationError(null, new CommunicationErrorEventArgs(httpCode, BlipActions.AfterUpdate));
                return;
            }

            if ((state & BlipCommunicationState.Error) == BlipCommunicationState.Error && ExceptionOccure != null)
            {
                ExceptionOccure(null, new ExceptionEventArgs(exp));
                return;
            }

            if (statuses == null)
                return;

            //gdy zostały zwrócone jakieś statusy
            if ((statuses.Count > 0) && (StatusesUpdated != null))
            {
                //zgłaszamy zdarzenie że dane załadowaliśmy, przekazując nasze parametry zgłosznie wraz z statusami
                StatusesUpdated(null, new StatusesLoadingEventArgs(statuses));
            }
        }