disconnect from API in c#

Hello ,
I ahve a small c# program
and I want to know how can I disconnect from the unit ?
is there any “quit API” command?
Thanks ,

Well, there is a “/quit” command, yes. And that would make RouterOS terminate the connection.

To terminate it on the client side (ideally after calling “/quit” and waiting for the !fatal reply)… Depends on the exact client, but I’d hope that if it doesn’t have a disconnect() method, it would at least close automatically when garbage collected, i.e. when there are no references to the object.

OK - thanks .,

1 more question about it

I have made a command that change the IP of the unit
and now - the application get stuck after it
this is what I did -

mikrotik.Send("ip/address/set");
mikrotik.Send("=.id=" +etherID);
mikrotik.Send("=address=" + NewIP , true);
foreach (string h in mikrotik.Read())
{}
messageBox.Show("reboot the software!");
Close();

the code is working , and I can see it change the IP of the device , but when I debug it - it doesn’t get to the “Close” command
and if I run the apllication as is - it get stuck after the cange
so what do I need to so it won’t “stuck” ?

Thanks ,

What does Read() do really? Read one sentence? Read until a !done sentence? Read until a timeout? Does it produce a single array/list that foreach is iterating over, or is it returning an iterator? Does it throw an exception?

Debug this code with Visual Studio (place a breakpoint before the foreach), and see what it’s doing, and what is h on each iteration, and if there are any exceptions.

the mikrotik.read is the default code from the mikrotik wiki
if I understadn correct it the simple read() of c#
when I debug it - it get stuck on -

foreach (string h in mikrotik.Read())

so I think the code is waiting for the read command to finish?
I don’t get any exceptions - nothing

so what else I can do? and can I check it deeper?

Thanks ,