示例#1
0
        public T ProcessRequest <T>(YamsterHttpRequest request)
        {
            AsyncRestCall call = CreateRequestObject(request);

            call.ProcessThreadsafe();
            byte[] bytes = call.GetResult();
            return(YamsterApi.ParseJsonResponse <T>(bytes));
        }
示例#2
0
        public async Task <byte[]> ProcessRawRequestAsync(YamsterHttpRequest request)
        {
            AsyncRestCall asyncRestCall = CreateRequestObject(request);

            asyncRestCall.Semaphore = new SemaphoreSlim(initialCount: 0, maxCount: 1);
            this.EnsureBackgroundThreadStarted();
            lock (this.lockObject)
            {
                RequestQueue.AddLast(asyncRestCall);
                backgroundThreadEvent.Set();
            }

            await asyncRestCall.Semaphore.WaitAsync();

            asyncRestCall.Semaphore.Dispose();

            byte[] bytes = asyncRestCall.GetResult();
            return(bytes);
        }