J
J
Joker4562017-08-11 06:58:10
.NET
Joker456, 2017-08-11 06:58:10

C# TCP client - Performing transfer on all forms without interruption?

Good day to all, I have a server on tcp and a client with several WinForms. What can be done to call Connect on 1 form, and on the next ones, only pass the values ​​​​for sending.
1. Form 1 - Connect
2. Send/receive byte array (Form 1)
3. Transition to Form 2
4. Send/receive byte array (Form 2)
5. Transition to Form 3
6. Send/receive byte array (Form 2 )
As a result, you need 1 Connect on 1 form, and then only receive and transmit data. Interruption of communication between the client and the server during the transition between forms is not allowed.
My actions:
1. Thread, Task - can only be called by 1 form, when switching to another form, the thread ends (it almost didn’t work out with it)
2. OOP - created a separate class for connections, connect, receive, etc. I call on the form 1 connect and transfer the array, then I go to the form, I start transferring the byte array and the error requires connect i.e. the connection was terminated.
Where to dig, tell me what to use?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2017-08-11
@Joker456

We created a class for the connection, and then, when creating new forms, pass its instance through the parameters of the form constructor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question