Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing IDisposable interface and possibility to stop Socket operations in FbRemoteEvent [DNET171] #179

Closed
firebird-automations opened this issue Jul 30, 2008 · 8 comments

Comments

@firebird-automations
Copy link

Submitted by: Pavel (chpasha)

is it possible to implement an IDisposable pattern for FbRemoteEvent? There are a lot of small problems now. For instance:
if you pass an connection object to the FbRemoteEvent constructor there are two possibilities
1) you are as owner responsible for destroying this connection object - doesn't work for now, if you dispose connection, there is a socket exception, cause RemoteEvent still tries to read from already disposed stream
2) FbRemoteEvent should destroy it - there is no place in code, where FbRemoteEvent would manage connection dispose. As i understand, you cannot stop it from listening at all. the thread, that is reading responses from server is declared "background" and reads until owning window is destroyed (and causes bunch of ThreadAbortedException's)

to understand the problem, consider this test case

FbConnection conn1 = new FbConnection("");
conn1.Open();
revent = new FbRemoteEvent(conn1, new[] { "event" });
revent.RemoteEventCounts += revent_RemoteEventCounts;
revent.QueueEvents();

revent.CancelEvents();
revent.RemoteEventCounts -= revent_RemoteEventCounts;
revent.Connection = null;
//this will cause an socket exception
conn1.Dispose();

Is there any possibility to implement some Stop method (that causes stoppage of all socket/thread stuff) - in my opinion - CancelEvents might do this work. And it would be nice to know, that the same functionality (and also dispose of connection) would be done in Dispose method. We can still dispose connection on our own, but only if we can stop socket listening (and this must be clearly stated in docu).

Commits: 17b734e

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Hello, I've implemented IDisposable as a first draft. And also CancelEvents will stop listening for events. Check <http://cid-bdb67deba4c656e5.skydrive.live.com/self.aspx/Ve%c5%99ejn%c3%a9/FirebirdClient|_IDisposableFbRemoteEvent|_|0|_CancelEvents/FirebirdSql.Data.FirebirdClient.dll>.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

rev.704

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5.0 Alpha 3 [ 10261 ]

Fix Version: 2.5.0 [ 10170 ]

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Opened for better implementation. Check next comment.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Resolved [ 5 ] => Reopened [ 4 ]

resolution: Fixed [ 1 ] =>

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Now the connection should behave properly. So if you close the connection, the events are stopped.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Reopened [ 4 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5.0 Beta 2 [ 10340 ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

Fix Version: 2.5.0 Beta 1 [ 10261 ] =>

Fix Version: 2.5.0 [ 10170 ] =>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants