Skip to content

SftpUpload() callback executed out of order #1043

@dca00

Description

@dca00

Discussed in #1042

Originally posted by dca00 November 10, 2022
In a simple console app, I pass to SftpClient.SftpUpload() a callback that writes progress to console. Before and after the call I write 'Start' and 'End'. Below is its output:

Start.
X=32739
X=65478
X=98217
X=130956
X=163695
X=229173
X=261912
X=262144
X=196434 <---=== Huh?
End.
Start.
X=32739
X=130956
X=163695
X=196434
X=229173
X=261912
X=262144
End. <---=== Huh?
X=98217 <---=== Huh?
X=65478 <---=== Huh?
Start.
End. <---=== Huh?
X=32739
X=98217
X=130956
X=163695
X=196434
X=229173
X=261912
X=262144
X=65478 <---=== Huh?

Any ideas as to what I am doing wrong?

            Console.WriteLine($"Start.");
            using (var sftp = new SftpClient("1.1.1.2", "root", "root"))
            {
                File.WriteAllBytes("test.fil", Enumerable.Repeat<byte>((byte)0, 256 * 1024).ToArray());

                using (var stream = File.OpenRead("test.fil"))
                {
                    sftp.Connect();
                    sftp.ChangeDirectory(".");
                    sftp.UploadFile(stream, "test.fil", new Action<ulong>(x =>
                    {
                        Console.WriteLine($"X={x}");
                    }));
                }

                Console.WriteLine($"End.");
            }
```</div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions