Conversation
|
|
||
| private readonly CancellationTokenSource source = new(); | ||
|
|
||
| public CancellationTokenSource GetSource => source; |
There was a problem hiding this comment.
Свойства обычно не именуют с Get
| this.address = adress; | ||
| } | ||
|
|
||
| // Принять сообщение |
There was a problem hiding this comment.
Для private-функции XML Documentation тоже вполне можно писать. Обычные комментарии используются для комментирования внутри тел методов в основном.
| // Принять сообщение | ||
| private async Task GetMessage(NetworkStream stream) { | ||
| using var streamReader = new StreamReader(stream); | ||
| var data = (await streamReader.ReadLineAsync()); |
There was a problem hiding this comment.
Suggested change
| var data = (await streamReader.ReadLineAsync()); | |
| var data = await streamReader.ReadLineAsync(); |
| // Отправить сообщение | ||
| private async Task SendMessage(NetworkStream stream) | ||
| { | ||
| using var streamWriter = new StreamWriter(stream) { AutoFlush = true}; |
There was a problem hiding this comment.
Suggested change
| using var streamWriter = new StreamWriter(stream) { AutoFlush = true}; | |
| using var streamWriter = new StreamWriter(stream) { AutoFlush = true }; |
| { | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
Тут ни одного блокирующего вызова нет — цикл, производящий миллионы задач просто
|
|
||
| private readonly CancellationTokenSource source = new(); | ||
|
|
||
| public CancellationTokenSource GetSource => source ; |
There was a problem hiding this comment.
Suggested change
| public CancellationTokenSource GetSource => source ; | |
| public CancellationTokenSource GetSource => source; |
| // Блокируем поток до установления соединения | ||
| var acceptedSocket = await tcpListener.AcceptSocketAsync(); | ||
| // Поток для записи и чтения в полученный сокет | ||
| using var newtworkStream = new NetworkStream(acceptedSocket); |
Comment on lines
+43
to
+44
| Task a = Task.Run(() => SendMessage(newtworkStream)); | ||
| Task b = Task.Run(() => GetMessage(newtworkStream)); |
There was a problem hiding this comment.
Их бы запоминать и подождать в конце метода
|
|
||
| public class Tests2Tests | ||
| { | ||
| Server? server; |
| [Test] | ||
| public void Test1() | ||
| { | ||
|
|
There was a problem hiding this comment.
:(. Впрочем, подозреваю, что Вы всю пару разбирались, почему клиент не запускается
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.