{"id":3934,"date":"2023-06-29T20:57:49","date_gmt":"2023-06-29T18:57:49","guid":{"rendered":"https:\/\/cplugin.com\/?post_type=docs&#038;p=3934"},"modified":"2023-06-29T20:58:49","modified_gmt":"2023-06-29T18:58:49","password":"","slug":"connection-pool","status":"publish","type":"docs","link":"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/","title":{"rendered":"Connection pool"},"content":{"rendered":"\n<p>For convenience we have created two classes to enable pool based connections to the MT4 server: ManagerPool and ManagerPoolEx.<\/p>\n\n\n\n<p>For example, you need to manipulate data at MT4 from multiple threads. ManagerAPI is single threaded.&nbsp;ManagerPool makes multiple connections to the MT4 server. And you can get available connecting from pool. It increases total performance at the expense of load to MT4 server.<\/p>\n\n\n\n<p>Example below shows a pool with 8 elements. And 100 threads simultaneously tries to get data from MT4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">public static class ManagerPollExamples\n{\n    private static readonly Logger Log = LogManager.GetCurrentClassLogger();\n \n    public static void GetUsers()\n    {\n        var pool = new ManagerPool(Constants.Server, Constants.Login, Constants.Password, maxPollSize: 8)\n        {\n            Logger = (ctx, type, message, exception) =&gt;\n            {\n                if (exception != null)\n                    Log.Error(exception);\n                else\n                    Log.Info($\"[{type}] {message}\");\n            }\n        };\n \n        pool.Run();\n \n        Parallel.For(0, 100, (l, state) =&gt;\n        {\n            using (var poolElement = pool.Get(TimeSpan.FromSeconds(3)))\n            {\n                var sw = new Stopwatch();\n                sw.Start();\n                Log.Debug($\"[{l}] requesting users...\");\n                var allUsers = poolElement.Data.Value.UsersRequest();\n                sw.Stop();\n                Log.Debug($\"[{l}] {allUsers.Count} users requested within {sw.Elapsed}\");\n            }\n        });\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For convenience we have created two classes to enable pool based connections to the MT4 server: ManagerPool and ManagerPoolEx. For example, you need to manipulate data at MT4 from multiple threads. ManagerAPI is single threaded.&nbsp;ManagerPool makes multiple connections to the MT4 server. And you can get available connecting from pool. It increases total performance at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"doc_category":[95],"doc_tag":[],"class_list":["post-3934","docs","type-docs","status-publish","hentry","doc_category-mt4-managerapi-net-wrapper"],"year_month":"2026-06","word_count":166,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Vladislav Sorokin","author_nicename":"cplugin","author_url":"https:\/\/cplugin.com\/blog\/author\/cplugin\/"},"doc_category_info":[{"term_name":"MT4 ManagerAPI .NET Wrapper","term_url":"https:\/\/cplugin.com\/docs-category\/mt4-managerapi-net-wrapper\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Connection pool - CPlugin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Connection pool - CPlugin\" \/>\n<meta property=\"og:description\" content=\"For convenience we have created two classes to enable pool based connections to the MT4 server: ManagerPool and ManagerPoolEx. For example, you need to manipulate data at MT4 from multiple threads. ManagerAPI is single threaded.&nbsp;ManagerPool makes multiple connections to the MT4 server. And you can get available connecting from pool. It increases total performance at [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/\" \/>\n<meta property=\"og:site_name\" content=\"CPlugin\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cplugin\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-29T18:58:49+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@CPlugin_com\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/\",\"url\":\"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/\",\"name\":\"Connection pool - CPlugin\",\"isPartOf\":{\"@id\":\"https:\/\/cplugin.com\/#website\"},\"datePublished\":\"2023-06-29T18:57:49+00:00\",\"dateModified\":\"2023-06-29T18:58:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cplugin.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Docs\",\"item\":\"https:\/\/cplugin.com\/wiki\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Connection pool\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cplugin.com\/#website\",\"url\":\"https:\/\/cplugin.com\/\",\"name\":\"CPlugin\",\"description\":\"CPlugin offers software and services to Forex brokers who use MetaQuotes MetaTrader 4 and 5 which are most advanced and reliable trading platforms.\",\"publisher\":{\"@id\":\"https:\/\/cplugin.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cplugin.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cplugin.com\/#organization\",\"name\":\"CPlugin Ltd.\",\"url\":\"https:\/\/cplugin.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cplugin.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.cplugin.com\/wp-content\/uploads\/2021\/07\/CPlugin-logo-1.png\",\"contentUrl\":\"https:\/\/www.cplugin.com\/wp-content\/uploads\/2021\/07\/CPlugin-logo-1.png\",\"width\":1823,\"height\":677,\"caption\":\"CPlugin Ltd.\"},\"image\":{\"@id\":\"https:\/\/cplugin.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/cplugin\",\"https:\/\/x.com\/CPlugin_com\",\"https:\/\/www.linkedin.com\/company\/cplugin\",\"https:\/\/www.youtube.com\/c\/CPlugin_com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Connection pool - CPlugin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/","og_locale":"en_US","og_type":"article","og_title":"Connection pool - CPlugin","og_description":"For convenience we have created two classes to enable pool based connections to the MT4 server: ManagerPool and ManagerPoolEx. For example, you need to manipulate data at MT4 from multiple threads. ManagerAPI is single threaded.&nbsp;ManagerPool makes multiple connections to the MT4 server. And you can get available connecting from pool. It increases total performance at [&hellip;]","og_url":"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/","og_site_name":"CPlugin","article_publisher":"https:\/\/www.facebook.com\/cplugin","article_modified_time":"2023-06-29T18:58:49+00:00","twitter_card":"summary_large_image","twitter_site":"@CPlugin_com","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/","url":"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/","name":"Connection pool - CPlugin","isPartOf":{"@id":"https:\/\/cplugin.com\/#website"},"datePublished":"2023-06-29T18:57:49+00:00","dateModified":"2023-06-29T18:58:49+00:00","breadcrumb":{"@id":"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cplugin.com\/docs\/mt4-managerapi-net-wrapper\/connection-pool\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cplugin.com\/"},{"@type":"ListItem","position":2,"name":"Docs","item":"https:\/\/cplugin.com\/wiki\/"},{"@type":"ListItem","position":3,"name":"Connection pool"}]},{"@type":"WebSite","@id":"https:\/\/cplugin.com\/#website","url":"https:\/\/cplugin.com\/","name":"CPlugin","description":"CPlugin offers software and services to Forex brokers who use MetaQuotes MetaTrader 4 and 5 which are most advanced and reliable trading platforms.","publisher":{"@id":"https:\/\/cplugin.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cplugin.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cplugin.com\/#organization","name":"CPlugin Ltd.","url":"https:\/\/cplugin.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cplugin.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.cplugin.com\/wp-content\/uploads\/2021\/07\/CPlugin-logo-1.png","contentUrl":"https:\/\/www.cplugin.com\/wp-content\/uploads\/2021\/07\/CPlugin-logo-1.png","width":1823,"height":677,"caption":"CPlugin Ltd."},"image":{"@id":"https:\/\/cplugin.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cplugin","https:\/\/x.com\/CPlugin_com","https:\/\/www.linkedin.com\/company\/cplugin","https:\/\/www.youtube.com\/c\/CPlugin_com"]}]}},"_links":{"self":[{"href":"https:\/\/cplugin.com\/wp-json\/wp\/v2\/docs\/3934","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cplugin.com\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/cplugin.com\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/cplugin.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cplugin.com\/wp-json\/wp\/v2\/comments?post=3934"}],"version-history":[{"count":2,"href":"https:\/\/cplugin.com\/wp-json\/wp\/v2\/docs\/3934\/revisions"}],"predecessor-version":[{"id":3937,"href":"https:\/\/cplugin.com\/wp-json\/wp\/v2\/docs\/3934\/revisions\/3937"}],"wp:attachment":[{"href":"https:\/\/cplugin.com\/wp-json\/wp\/v2\/media?parent=3934"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/cplugin.com\/wp-json\/wp\/v2\/doc_category?post=3934"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/cplugin.com\/wp-json\/wp\/v2\/doc_tag?post=3934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}