Example #1
0
 public void CancelEvents(RemoteEvent remoteEvent)
 {
     lock (this.events.SyncRoot)
     {
         this.events.Remove(remoteEvent.LocalId);
     }
 }
        public void QueueEvents(RemoteEvent remoteEvent)
        {
            lock (this)
            {
                if (!this.events.ContainsKey(remoteEvent.LocalId))
                {
                    lock (this.events.SyncRoot)
                    {
                        this.events.Add(remoteEvent.LocalId, remoteEvent);
                    }
                }

#if	(!NET_CF)
                if (this.eventsThread == null ||
                    (this.eventsThread.ThreadState != ThreadState.Running &&
                    this.eventsThread.ThreadState != ThreadState.Background))
#else
                if (this.eventsThread == null)
#endif
                {
#if (NET_CF)
                    this.eventsThread = new Thread(new ThreadStart(() => ThreadHandler(this.syncControl)));
#else
                    this.eventsThread = new Thread(new ThreadStart(() => ThreadHandler(this.syncContext)));
#endif
                    this.eventsThread.IsBackground = true;
                    this.eventsThread.Name = "FirebirdClient - Events Thread";
                    this.eventsThread.Start();
                }
            }
        }
		public void QueueEvents(RemoteEvent remoteEvent)
		{
			lock (this)
			{
				lock (this.events.SyncRoot)
				{
					if (!this.events.ContainsKey(remoteEvent.LocalId))
					{
						this.events.Add(remoteEvent.LocalId, remoteEvent);
					}
				}

#if	(!NETCF)
				if (this.thread == null ||
					(this.thread.ThreadState != ThreadState.Running && this.thread.ThreadState != ThreadState.Background))
#else
				if (this.thread == null)
#endif
				{
					this.thread = new Thread(new ThreadStart(ThreadHandler));
					this.thread.Start();
					this.thread.IsBackground = true;
				}
			}
		}
		/// <include file='Doc/en_EN/FbRemoteEvent.xml'	path='doc/class[@name="FbRemoteEvent"]/constructor[@name="ctor(FbConnection, System.Array)"]/*'/>
		public FbRemoteEvent(FbConnection connection, string[] events)
		{
			if (connection == null || connection.State != System.Data.ConnectionState.Open)
			{
				throw new InvalidOperationException("Connection must valid and open");
			}
			this.connection = connection;
			this.revent		= connection.InnerConnection.Database.CreateEvent();
			this.revent.EventCountsCallback = new EventCountsCallback(this.OnRemoteEventCounts);

			if (events != null)
			{
				this.AddEvents(events);
			}
		}
		public void QueueEvents(RemoteEvent remoteEvent)
		{
			lock (this)
			{
				_events[remoteEvent.LocalId] = remoteEvent;

				// Jiri Cincura: I'm pretty sure this is a race condition.
				if (_eventsThread == null || _eventsThread.ThreadState.HasFlag(ThreadState.Stopped | ThreadState.Unstarted))
				{
					_eventsThread = new Thread(ThreadHandler);
					_eventsThread.IsBackground = true;
					_eventsThread.Name = "FirebirdClient - Events Thread";
					_eventsThread.Start();
				}
			}
		}
Example #6
0
 public abstract void QueueEvents(RemoteEvent events);
Example #7
0
        public void CancelEvents(RemoteEvent events)
        {
            lock (this.SyncObject)
            {
                try
                {
                    this.Write(IscCodes.op_cancel_events);	// Op code
                    this.Write(this.handle);				// Database	object id
                    this.Write(events.LocalId);			    // Event ID

                    this.Flush();

                    this.ReadResponse();

                    this.eventManager.CancelEvents(events);
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
Example #8
0
        public void QueueEvents(RemoteEvent events)
        {
            if (this.eventManager == null)
            {
                string ipAddress = string.Empty;
                int portNumber = 0;
                int auxHandle = 0;

                this.ConnectionRequest(out auxHandle, out ipAddress, out portNumber);

                this.eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
            }

            lock (this.SyncObject)
            {
                try
                {
                    events.LocalId = ++this.eventsId;

                    EventParameterBuffer epb = events.ToEpb();

                    this.Write(IscCodes.op_que_events); // Op codes
                    this.Write(this.handle);			// Database	object id
                    this.WriteBuffer(epb.ToArray());	// Event description block
                    this.Write(0);						// Address of ast routine
                    this.Write(0);						// Argument	to ast routine
                    this.Write(events.LocalId);		    // Client side id of remote	event

                    this.Flush();

                    GenericResponse response = (GenericResponse)this.ReadResponse();

                    // Update event	Remote event ID
                    events.RemoteId = response.ObjectHandle;

                    // Enqueue events in the event manager
                    this.eventManager.QueueEvents(events);
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
		public void QueueEvents(RemoteEvent events)
		{
			if (_eventManager == null)
			{
				string ipAddress = string.Empty;
				int portNumber = 0;
				int auxHandle = 0;

				ConnectionRequest(out auxHandle, out ipAddress, out portNumber);

				_eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
			}

			lock (SyncObject)
			{
				try
				{
					events.LocalId = Interlocked.Increment(ref _eventsId);

					// Enqueue events in the event manager
					_eventManager.QueueEvents(events);

					EventParameterBuffer epb = events.ToEpb();

					XdrStream.Write(IscCodes.op_que_events);
					XdrStream.Write(_handle);                 // Database object id
					XdrStream.WriteBuffer(epb.ToArray());     // Event description block
					XdrStream.Write(0);                       // Address of ast routine
					XdrStream.Write(0);                       // Argument to ast routine
					XdrStream.Write(events.LocalId);          // Client side id of remote event

					XdrStream.Flush();

					GenericResponse response = (GenericResponse)ReadResponse();

					// Update event	Remote event ID
					events.RemoteId = response.ObjectHandle;
				}
				catch (IOException ex)
				{
					throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex);
				}
			}
		}
		public void CancelEvents(RemoteEvent events)
		{
			lock (SyncObject)
			{
				try
				{
					XdrStream.Write(IscCodes.op_cancel_events);
					XdrStream.Write(_handle);             // Database object id
					XdrStream.Write(events.LocalId);      // Event ID

					XdrStream.Flush();

					ReadResponse();

					_eventManager.CancelEvents(events);
				}
				catch (IOException ex)
				{
					throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex);
				}
			}
		}
Example #11
0
 public abstract void CancelEvents(RemoteEvent events);
Example #12
0
 public abstract ValueTask CancelEventsAsync(RemoteEvent events, CancellationToken cancellationToken = default);
		public FbRemoteEvent(FbConnection connection, params string[] events)
		{
			if (connection == null || connection.State != System.Data.ConnectionState.Open)
			{
				throw new InvalidOperationException("Connection must be valid and open");
			}

			_connection = connection;
			_revent = connection.InnerConnection.Database.CreateEvent();
			_revent.EventCountsCallback = new RemoteEventCountsCallback(OnRemoteEventCounts);
			_synchronizationContext = SynchronizationContext.Current ?? new SynchronizationContext();

			if (events != null)
			{
				AddEvents(events);
			}
		}
		public void CancelEvents(RemoteEvent remoteEvent)
		{
			RemoteEvent dummy;
			_events.TryRemove(remoteEvent.LocalId, out dummy);
		}
Example #15
0
        public void QueueEvents(RemoteEvent remoteEvent)
        {
            lock (this)
            {
                if (!this.events.ContainsKey(remoteEvent.LocalId))
                {
                    lock (this.events.SyncRoot)
                    {
                        this.events.Add(remoteEvent.LocalId, remoteEvent);
                    }
                }

                if (this.eventsThread == null || this.eventsThread.ThreadState.HasFlag(ThreadState.Stopped | ThreadState.Unstarted))
                {
                    this.eventsThread = new Thread(new ThreadStart(() => ThreadHandler(this.syncContext)));
                    this.eventsThread.IsBackground = true;
                    this.eventsThread.Name = "FirebirdClient - Events Thread";
                    this.eventsThread.Start();
                }
            }
        }
		void IDatabase.CancelEvents(RemoteEvent events)
		{
			throw new NotSupportedException();
		}
		public void CancelEvents(RemoteEvent events)
		{
			lock (SyncObject)
			{
				try
				{
					Write(IscCodes.op_cancel_events);
					Write(_handle);             // Database object id
					Write(events.LocalId);      // Event ID

					Flush();

					ReadResponse();

					_eventManager.CancelEvents(events);
				}
				catch (IOException)
				{
					throw new IscException(IscCodes.isc_net_read_err);
				}
			}
		}
		public void CancelEvents(RemoteEvent events)
		{
			throw new NotSupportedException();
		}
Example #19
0
 public abstract Task CancelEvents(RemoteEvent events, AsyncWrappingCommonArgs async);