Beispiel #1
0
		public async Task<List<OSCPacket>> Call (OSCPacket p)
		{
			// generate unique id
			var currentMessageId = Interlocked.Increment (ref safeMessageCount);
			var id = String.Concat (Name, "_", currentMessageId);

			// add result object
			var result = new MadMapperResult (id);
			while (!results.TryAdd (id, result)) {
			}

			// add id to message as parameter
			p.Address += "&id=" + id;

			// send message
			Send (p);

			// wait for all messages
			await Task.Run (() => {
				while (!result.Finished) {
					newMessageArrived.WaitOne ();
					newMessageArrived.Reset ();
				}
			});

			// remove result object
			MadMapperResult removedObject;

			while (!results.TryRemove (id, out removedObject)) {
			}

			return result.Packets;
		}
Beispiel #2
0
        public async Task <List <OSCPacket> > Call(OSCPacket p)
        {
            // generate unique id
            var currentMessageId = Interlocked.Increment(ref safeMessageCount);
            var id = String.Concat(Name, "_", currentMessageId);

            // add result object
            var result = new MadMapperResult(id);

            while (!results.TryAdd(id, result))
            {
            }

            // add id to message as parameter
            p.Address += "&id=" + id;

            // send message
            Send(p);

            // wait for all messages
            await Task.Run(() => {
                while (!result.Finished)
                {
                    newMessageArrived.WaitOne();
                    newMessageArrived.Reset();
                }
            });

            // remove result object
            MadMapperResult removedObject;

            while (!results.TryRemove(id, out removedObject))
            {
            }

            return(result.Packets);
        }