Exemple #1
0
 public static async Task <bool> ExistsAsync(string path)
 {
     return(await EmcTask <bool> .Run(() =>
     {
         return Exists(path);
     }).ConfigureAwait(false));
 }
Exemple #2
0
 public static async Task <IEnumerable <string> > EnumerateDirectoriesAsync(string path, string searchPattern, SearchOption searchOption)
 {
     return(await EmcTask <string[]> .Run(() =>
     {
         return EnumerateDirectories(path, searchPattern, searchOption);
     }).ConfigureAwait(false));
 }
Exemple #3
0
 public static async Task <IEnumerable <string> > EnumerateFilesAsync(string path, string searchPattern)
 {
     return(await EmcTask <IEnumerable <string> > .Run(() =>
     {
         return EnumerateFiles(path, searchPattern);
     }).ConfigureAwait(false));
 }
Exemple #4
0
 public static async Task <IEnumerable <string> > EnumerateDirectoriesAsync(string path)
 {
     return(await EmcTask <IEnumerable <string> > .Run(() =>
     {
         return EnumerateDirectories(path);
     }).ConfigureAwait(false));
 }
Exemple #5
0
 public static async Task WriteJsonAsync(string filename, object value, bool formatting = false)
 {
     await EmcTask.Run(() =>
     {
         WriteJson(filename, value, formatting);
     }).ConfigureAwait(false);
 }
Exemple #6
0
 public static async Task CopyAsync(string sourcePath, string destinationPath, bool overwrite)
 {
     await EmcTask.Run(() =>
     {
         Copy(sourcePath, destinationPath, overwrite);
     }).ConfigureAwait(false);
 }
Exemple #7
0
        public static bool Ping(string ipAddress, int timeout = 2000, int retries = 5)
        {
            var task = EmcTask <bool> .Run(async() =>
            {
                using (var pingSender = new Ping())
                {
                    var options = new PingOptions
                    {
                        DontFragment = true
                    };

                    string data = "12345678901234567890123456789012";

                    byte[] buffer = Encoding.ASCII.GetBytes(data);
                    try
                    {
                        for (int retry = 0; retry < retries; retry++)
                        {
                            if ((await pingSender.SendPingAsync(ipAddress, timeout, buffer, options).ConfigureAwait(false)).Status == IPStatus.Success)
                            {
                                return(true);
                            }
                        }
                    }
                    catch { }
                    return(false);
                }
            });

            task.Wait();
            return(task.Result);
        }
Exemple #8
0
 public static async Task DeleteAsync(string path, bool recursive)
 {
     await EmcTask.Run(() =>
     {
         Delete(path, recursive);
     }).ConfigureAwait(false);
 }
Exemple #9
0
 public static async Task <string> ReadAllTextAsync(string fileName)
 {
     return(await EmcTask.Run <string>(() =>
     {
         return ReadAllText(fileName);
     }).ConfigureAwait(false));
 }
Exemple #10
0
 public static async Task AppendAllTextAsync(string fileName, string text)
 {
     await EmcTask.Run(() =>
     {
         AppendAllText(fileName, text);
     }).ConfigureAwait(false);
 }
Exemple #11
0
 public static async Task CopyAsync(string sourceFileName, string destinationFileName, bool overwrite = false)
 {
     await EmcTask.Run(() =>
     {
         Copy(sourceFileName, destinationFileName, overwrite);
     }).ConfigureAwait(false);
 }
Exemple #12
0
 public static async Task EnsureExistDeleteAsync(string fileName)
 {
     await EmcTask.Run(() =>
     {
         EnsureExistDelete(fileName);
     }).ConfigureAwait(false);
 }
Exemple #13
0
 public static async Task <bool> ExistAsync(string fileName)
 {
     return(await EmcTask <bool> .Run(() =>
     {
         return Exist(fileName);
     }).ConfigureAwait(false));
 }
Exemple #14
0
 public static async Task CreateDirectoryAsync(string path)
 {
     await EmcTask.Run(() =>
     {
         CreateDirectory(path);
     }).ConfigureAwait(false);
 }
Exemple #15
0
 public static async Task <bool> PingAsync(string ipAddress, int timeout = 2000, int retries = 5)
 {
     return(await EmcTask <bool> .Run(() =>
     {
         return Ping(ipAddress, timeout, retries);
     }).ConfigureAwait(false));
 }
Exemple #16
0
 public static async Task ClearAsync(string path)
 {
     await EmcTask.Run(() =>
     {
         Clear(path);
     }).ConfigureAwait(false);
 }
Exemple #17
0
 public static async Task <string> EnsureDirectoryExistsAsync(string path)
 {
     return(await EmcTask <string> .Run(() =>
     {
         return EnsureDirectoryExists(path);
     }).ConfigureAwait(false));
 }
Exemple #18
0
 public static async Task <T> ReadJsonAsync <T>(string filename)
 {
     return(await EmcTask.Run <T>(() =>
     {
         return ReadJson <T>(filename);
     }).ConfigureAwait(false));
 }
Exemple #19
0
 public static async Task <bool> CheckPortUsageAsync(int port)
 {
     return(await EmcTask <bool> .Run(() => CheckPortUsage(port)).ConfigureAwait(false));
 }