예제 #1
0
        static async Task Main(string[] args)
        {
            if (args.Length != 2)
            {
                return;
            }

            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);

            _login = args[0];
            _dir   = args[1];
            var resp = await _client.GetAsync($"{ServerUrl}/authenticate/{_login}");

            if (!resp.IsSuccessStatusCode)
            {
                Console.WriteLine(await resp.Content.ReadAsStringAsync());
                return;
            }

            Directory.CreateDirectory(_dir);
            TransferManager.Start(_dir, _login);    //na innym wątku

            while (true)
            {
                Console.Clear();
                PrintLoginDirectoryInfo(_login, _dir);
                Console.WriteLine("Files in progress:");
                foreach (var fileTranfer in TransferManager.ProcessingFiles.Values)
                {
                    Console.WriteLine($"{fileTranfer.Filename} : {fileTranfer.FileStatus}");
                }

                Console.WriteLine("Local Files:");
                ListFilesInDirectory(_dir);

                Thread.Sleep(500);     // 0,5 s
            }
        }