|
|
|
@ -2,44 +2,50 @@
@@ -2,44 +2,50 @@
|
|
|
|
|
using System.IO; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
namespace EquivalentCSharpConsoleApp |
|
|
|
|
using Microsoft.VisualBasic.CompilerServices; |
|
|
|
|
|
|
|
|
|
[StandardModule] |
|
|
|
|
internal sealed class AsyncProgram |
|
|
|
|
{ |
|
|
|
|
static class Program |
|
|
|
|
{ |
|
|
|
|
[STAThread] |
|
|
|
|
public static void Main(string[] args) |
|
|
|
|
{ |
|
|
|
|
var task = new Task(ProcessDataAsync); |
|
|
|
|
Task task = new Task(ProcessDataAsync); |
|
|
|
|
task.Start(); |
|
|
|
|
task.Wait(); |
|
|
|
|
Console.ReadLine(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async static void ProcessDataAsync() |
|
|
|
|
public static async void ProcessDataAsync() |
|
|
|
|
{ |
|
|
|
|
Task<int> task = HandleFileAsync("C:\\enable1.txt"); |
|
|
|
|
Console.WriteLine("Please wait, processing"); |
|
|
|
|
int result = await task; |
|
|
|
|
Console.WriteLine("Count: " + result.ToString()); |
|
|
|
|
Console.WriteLine("Count: " + await task); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async static Task<int> HandleFileAsync(string file) |
|
|
|
|
public static async Task<int> HandleFileAsync(string file) |
|
|
|
|
{ |
|
|
|
|
Console.WriteLine("HandleFile enter"); |
|
|
|
|
int count = 0; |
|
|
|
|
using (StreamReader reader = new StreamReader(file)) |
|
|
|
|
int num = 0; |
|
|
|
|
checked |
|
|
|
|
{ |
|
|
|
|
using (StreamReader streamReader = new StreamReader(file)) |
|
|
|
|
{ |
|
|
|
|
string text = await streamReader.ReadToEndAsync(); |
|
|
|
|
num += text.Length; |
|
|
|
|
int num2 = 0; |
|
|
|
|
do |
|
|
|
|
{ |
|
|
|
|
string value = await reader.ReadToEndAsync(); |
|
|
|
|
count += value.Length; |
|
|
|
|
for (var i = 0; i <= 10000; i += 1) |
|
|
|
|
if (text.GetHashCode() == 0) |
|
|
|
|
{ |
|
|
|
|
var x = value.GetHashCode(); |
|
|
|
|
if (x == 0) |
|
|
|
|
count -= 1; |
|
|
|
|
num--; |
|
|
|
|
} |
|
|
|
|
num2++; |
|
|
|
|
} while (num2 <= 10000); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Console.WriteLine("HandleFile exit"); |
|
|
|
|
return count; |
|
|
|
|
return num; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |