static async void TestRemote() { ThreadPool.SetMinThreads(250, 250); var config = AsyncDecoderConfig.FromFile("./async_decoder_config.json"); config.EnableFakeDecoder = false; IDecoder decoder = new AsyncDecoder(config); byte[] mockWave = new byte[] { 1, 2, 3, 4 }; IList <Task <DecodeResult> > list = new List <Task <DecodeResult> >(); for (int i = 0; i < 200; i++) { Task <DecodeResult> task = decoder.DecodeAsync(new Speech { SpeechId = i.ToString(), Wave = mockWave }); //Thread.Sleep(2); list.Add(task); } for (int i = 0; i < 200; i++) { DecodeResult result = await list[i]; Console.WriteLine(result.Text + "|" + result.Message); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); String[] arguments = Environment.GetCommandLineArgs(); if (arguments.Length != 2) { Console.Error.WriteLine("Usage: dotnet Service.dll --decoder-config=<async_decoder_config.json>\n" + "<async_decoder_config.json> is the location that stores the " + "configuration for `AsyncDecoder`."); } AsyncDecoderConfig config = AsyncDecoderConfig.FromFile(Regex.Match(arguments[1], "--decoder-config=(.*)").Groups[1].Value); services.AddSingleton <IDecoder, AsyncDecoder>(decoder => new AsyncDecoder(config)); var logCfg = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"); Console.WriteLine("Using config: " + AppDomain.CurrentDomain.BaseDirectory + "log4net.config"); XmlConfigurator.ConfigureAndWatch(LogManager.GetRepository(Assembly.GetCallingAssembly()), logCfg); }