Beispiel #1
0
        Task <WatchValuesResponse> GetWatchChangesAsync(WatchChangesRequest req)
        {
            var    tcs       = new TaskCompletionSource <WatchValuesResponse> ();
            Action setResult = () => {
                tcs.SetResult(new WatchValuesResponse {
                    WatchValues = new Dictionary <string, List <string> > (WatchStore.Values),
                    Version     = WatchStore.Version,
                });
            };

            if (WatchStore.Version > req.Version)
            {
                setResult();
            }
            else
            {
                EventHandler handle = null;
                handle = (s, e) => {
                    if (WatchStore.Version > req.Version)
                    {
                        WatchStore.Recorded -= handle;
                        setResult();
                    }
                };
                WatchStore.Recorded += handle;
            }
            return(tcs.Task);
        }
Beispiel #2
0
		public async Task<WatchValuesResponse> WatchChangesAsync (long version)
		{
//			Console.WriteLine ("WC " + version);

			var req = new WatchChangesRequest { Version = version };

			var reqStr = JsonConvert.SerializeObject (req);

			var respStr = await client.UploadStringTaskAsync (watchChangesUrl, reqStr);

			return JsonConvert.DeserializeObject<WatchValuesResponse> (respStr);
		}
        public async Task <WatchValuesResponse> WatchChangesAsync(long version)
        {
//			Console.WriteLine ("WC " + version);

            var req = new WatchChangesRequest {
                Version = version
            };

            var reqStr = JsonConvert.SerializeObject(req);

            var respStr = await client.UploadStringTaskAsync(watchChangesUrl, reqStr);

            return(JsonConvert.DeserializeObject <WatchValuesResponse> (respStr));
        }
Beispiel #4
0
		Task<WatchValuesResponse> GetWatchChangesAsync (WatchChangesRequest req)
		{
			var tcs = new TaskCompletionSource<WatchValuesResponse> ();
			Action setResult = () => {
				tcs.SetResult (new WatchValuesResponse {
					WatchValues = new Dictionary<string, List<string>> (WatchStore.Values),
					Version = WatchStore.Version,
				});
			};
			if (WatchStore.Version > req.Version) {
				setResult ();
			} else {
				EventHandler handle = null;
				handle = (s, e) => {
					if (WatchStore.Version > req.Version) {
						WatchStore.Recorded -= handle;
						setResult ();
					}
				};
				WatchStore.Recorded += handle;
			}
			return tcs.Task;
		}