static void Main(string[] args) { //Use TCP Port. //If you are using Web application. Feel free to add ClickHouseConnection as Singleton. And add IClickHouseRepository as Scoped. //Take example here: // //[CODE] //services.AddScoped<IClickHouseRepository, ClickHouseRepository>(); //services.AddSingleton(x => new ClickHouseConnection(_configuration.GetValue<int>("Connection:Count"), _configuration.GetValue<string>("ConnectionStrings:SRV")) // .InitSemaphore(_configuration.GetValue<int>("Connection:InitialConcurrentCount"), _configuration.GetValue<int>("Connection:MaximumConcurrentCount"))); //[CODE] //If you don't need DI, just new object for yourself. //Parameter explain: 30 is ConnectionPool size. ClickHouseConnection _conn = new ClickHouseConnection(30, "Host=0.0.0.0;Port=9003;Database=Test;User=Test;Password=Test"); //Parameter explain: They are SemaphoreSlim initCount and maxCount _conn.InitSemaphore(20, 20); IClickHouseRepository repository = new ClickHouseRepository(_conn); //Take Repository instance. Invoke GetResultAsync, passing your logic code here var sql = @"SELECT ID, Name, Job FROM one_table"; var data = repository.GetResultAsync((conn) => GetSomeDataAsync(conn, sql)); //now you have the data. Console.WriteLine("Hello World!"); }