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

"System.ObjectDisposedException" in System.dll with Connection.LoadAsync<T> #9

Closed
seho85 opened this issue Apr 24, 2016 · 3 comments
Closed

Comments

@seho85
Copy link

seho85 commented Apr 24, 2016

Hey Daniel,

here I am again.
I found some time to play arround with tik4net.

I don't think I understand the code completly but it was enough to get the another Tool command running -
at least under special conditions.

Before I continoue - Thanks for your work. It gave me some great inspiration for another project.

Like told before I implemented MikroTik ping command, but I occured some trouble with an "System.ObjectDisposedException". It seams that the async call is not working, or I am missing something.

I created a little project, named tik4net.ping, which reproduces the behaviour on my fork of tik4net https://github.com/seho85/tik4net.git

When in the tik4net.ping project, in the file MainWindow.xaml.cs, in the method button_Click..., the non blocking delay loop is commented out the exception is thrown.

Maybe I am missing somethinh here, because I am not very familiar with async calls, but from my understanding of an async call it should work in my WPF example too.

Any help is appreciated.

Kinds regards,
Sebastian

@danikf
Copy link
Owner

danikf commented Apr 27, 2016

Hi Sebastian,

use Thread.Sleep(miliseconds) to wait ...

I have just commited PingTest test - it is partialy based on your code.

Enjoy,
D

@danikf danikf closed this as completed Apr 27, 2016
@danikf
Copy link
Owner

danikf commented Apr 27, 2016

I have re-read again your question. The answer is:

connection is disposed at the end od your "using" block. So - create/open instance of mikrotik connection during aplication start (and dispose it at the end) or wait for command response before you dispose connection object. You can not dispose connection and expect that you can get results from it.

I have also improved connection behavior to end async load process instead of throwing exception.

D

@seho85
Copy link
Author

seho85 commented Apr 29, 2016

Hey,

thanks for your response.

I already assumed that the failure was on my side. I somehow overlooked the behaviour of the using statement.

When I got the cosmetic work on my other changes to the code finished, and when got a litlte bit more familar with using github, i'll gonna provide my changes to the base repository.

Thanks again,

Kinds regards,
Sebastian

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

No branches or pull requests

2 participants