TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Donald C
NA
153
3.5k
HDI send a final msg via TcpClient before my class closes?
May 3 2016 8:56 AM
Hi Guys,
Im having trouble sending a final command to a service before my class closes.
I have a startupclient that starts when my application starts and attempts to send a "QUIT" message from the class destructor as the class is closing.
Unfortunately when calling SendCommand("QUIT") from the class destructor, I get an exception from the SendCommand method.
System.ObjectDisposedException was unhandled
HResult=-2146232798
Message=Cannot access a disposed object.
Object name: 'System.Net.Sockets.TcpClient'.
ObjectName=System.Net.Sockets.TcpClient
Source=System
StackTrace:
at System.Net.Sockets.TcpClient.GetStream()
at Skeleton.Classes.clsStartupClient.SendCommand(String Command, String Param)
at Skeleton.Classes.clsStartupClient.SendCommand(String Command)
at Skeleton.Classes.clsStartupClient.Finalize()
InnerException:
on the line below in the SendCommand() method.
StreamWriter wtr = new StreamWriter(Cli.GetStream());
How would I be able to send a final SendCommand message before the class closes?
Thanks in advance.
Attachment:
Startup.zip
Reply
Answers (
2
)
combining two arrays
How to get data from games