public static ISozlukRequestHandler PickRequest() { ISozlukRequestHandler req = null; mre.WaitOne(); if (cancelled) { return(null); } lock (synchObj) { if (Requests.Count > 0) { req = Requests.Dequeue(); } if (Requests.Count == 0) { mre.Reset(); } } return(req); }
private static ISozlukRequestHandler GetHandlerObject(RequestObject request) { ISozlukRequestHandler handler = null; RequestType rType; string typeString; if (!request.HasItem("RequestType")) { return(null); } typeString = request.GetItem <string>("RequestType"); if (!Enum.TryParse <RequestType>(typeString, out rType)) { return(null); } switch (rType) { case RequestType.EntryAdd: handler = new EntryAddHandler(request); break; case RequestType.EntryGet: handler = new EntryGetHandler(request); break; case RequestType.Search: handler = new IndexAndSearchHandler(request); break; case RequestType.UserGetPass: handler = new GetUserPassHandler(request); break; case RequestType.AuthSuser: handler = new AuthenticateSuserHandler(request); break; } Log.Info("Got an {0} type request", handler.GetType().FullName); return(handler); }