/// <summary> /// Get next identifier from sequence /// </summary> /// <returns></returns> public long GetNextIdLong() { // buffer a queue of ids on the client to reduce trips to server // http://social.msdn.microsoft.com/Forums/en/wcf/thread/0c71eedb-6c71-4b94-97c7-332195a7eb5c // annotation op invoker on services side modified to add one to avoid 512 byte problem if (SeqQueue.Count == 0) // get more ids from server if needed { if (SeqQueueRequestSize == 0) { SeqQueueRequestSize = 1; } else if (SeqQueueRequestSize < 1024) { SeqQueueRequestSize *= 2; // double size on each call until we get to 1k } if (ServiceFacade.UseRemoteServices) { Mobius.Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = ServiceFacade.InvokeNativeMethod(nativeClient, (int)Services.Native.ServiceCodes.MobiusAnnotationService, (int)Services.Native.ServiceOpCodes.MobiusAnnotationService.GetNextIdsLong, new Services.Native.NativeMethodTransportObject(new object[] { instanceId, SeqQueueRequestSize })); ((System.ServiceModel.IClientChannel)nativeClient).Close(); long[] ids = (long[])resultObject.Value; SeqQueue = new Queue <long>(ids); } else { long[] ids = Instance.GetNextIdsLong(SeqQueueRequestSize); SeqQueue = new Queue <long>(ids); } } long nextVal = SeqQueue.Dequeue(); // may overflow return(nextVal); }