Author: Copyright � 2006-2013, FINEXWARE GmbH
0 Views
0 Downloads
0 Favorites
mutex
//+------------------------------------------------------------------+
//|                                                            Mutex |
//|                            Copyright © 2006-2013, FINEXWARE GmbH |
//|                                                www.FINEXWARE.com |
//|      programming & development - Alexey Sergeev, Boris Gershanov |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006-2013, FINEXWARE GmbH"
#property link      "www.FINEXWARE.com"
#property version   "1.00"

#include <MQH\Lib\Mutex.mqh>

#property script_show_inputs

input int sleep=200;

//------------------------------------------------------------------
void OnStart()
{
	Sleep(5000); // ïîäîæäåì , ÷òîá óñïåëè êèíóòü ñêðèïò íà âòîðîé ÷àðò
	CMutexSync sync; // ñàì îáúåêò ñèíðîíèçàöèè
	if (!sync.Create("Local\\test")) { Print(Symbol()+" MutexSync create ERROR!"); return; }
	Print(Symbol()+" MutexSync created OK! Sleep=", sleep);
	
	for (int i=0; i<10; i++)
	{
		CMutexLock lock(sync, (DWORD)INFINITE); // ëî÷èì ó÷àñòîê â ýòèõ ñêîáêàõ
		Print(Symbol()+" lock scope"); Sleep(sleep);
	}
}
//+------------------------------------------------------------------+

Comments