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

Web chat #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Web chat #6

wants to merge 1 commit into from

Conversation

artemiipatov
Copy link
Owner

No description provided.

/// </summary>
public Client(string host, int port)
{
_client = new TcpClient(host, port);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так TcpClient сразу начнёт подключаться к хосту, синхронно. Правильнее было создать TcpClient конструктором без параметров, а потом, уже в RunAsync, вызвать ConnectAsync.

Comment on lines +16 to +17
await Task.Run(async () => await Post(stream));
await Task.Run(async () => await Get(stream));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так мы сначала должны будем дождаться выполнения Post, а уже затем переходить к Get. Что не очень для чата. Надо было

var task1 = Post(stream);
var task2 = Get(stream);
await task1;
await task2;

Есть большая разница, когда делать await

await writer.FlushAsync();
await stream.FlushAsync();

writer = null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Бесполезно, всё равно его перетрёт тут же

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

Successfully merging this pull request may close these issues.

2 participants