Skip to content
CPlugin logo
  • Home
  • Blog
  • Store
  • Contact
  • FAQ
  • Cart
  • My account
  • Knowledge Base
CPlugin logo
  • Home
  • Blog
  • Store
  • Contact
  • FAQ
  • Cart
  • My account
  • Knowledge Base

General

  • How to obtain files

MT4 ManagerAPI .NET Wrapper

  • Installation
  • Connection pool
  • Price Helper

Standalone Apps

  • Join two MT4 Servers
  • Compress MT4 database
  • Quotes Monitor
  • Quotes Monitor (WPF)
  • MT4 Report Server extended replication
  • EMIR
  • DividenderLT
  • Tools to calculate dividends
  • CopyTrading
    • Sentiment Strategy (LMAX)
    • MT4 (ManagerAPI) to LMAX
    • MT4 Plugin
    • MT4 (ManagerAPI) to MT4

Plugins for MT4/MT5

  • Flexible Leverage
  • GapHelper plugin
  • Multi Account Manager (MAM)
  • Spread Extender
  • HedgeHelper
  • Multi-Tier IB
  • Multi-Tier IB advanced version

Cloud

  • General info
  • WebAPI
    • WebAPI
    • Authorization
    • Pricing and terms
    • RESTful
    • Web Sockets (SignalR)
  • Home
  • Docs
  • MT4 ManagerAPI .NET Wrapper
  • Connection pool

Connection pool

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. 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.

Example below shows a pool with 8 elements. And 100 threads simultaneously tries to get data from MT4.

public static class ManagerPollExamples
{
    private static readonly Logger Log = LogManager.GetCurrentClassLogger();
 
    public static void GetUsers()
    {
        var pool = new ManagerPool(Constants.Server, Constants.Login, Constants.Password, maxPollSize: 8)
        {
            Logger = (ctx, type, message, exception) =>
            {
                if (exception != null)
                    Log.Error(exception);
                else
                    Log.Info($"[{type}] {message}");
            }
        };
 
        pool.Run();
 
        Parallel.For(0, 100, (l, state) =>
        {
            using (var poolElement = pool.Get(TimeSpan.FromSeconds(3)))
            {
                var sw = new Stopwatch();
                sw.Start();
                Log.Debug($"[{l}] requesting users...");
                var allUsers = poolElement.Data.Value.UsersRequest();
                sw.Stop();
                Log.Debug($"[{l}] {allUsers.Count} users requested within {sw.Elapsed}");
            }
        });
    }
}
Still stuck? How can we help?

How can we help?

Updated on June 29, 2023
InstallationPrice Helper

Powered by BetterDocs

Copyright © 2015  - 2025 CPlugin

Telegram Email EmailLinkedinFacebookTwitter

Powered by CPlugin