Get number of threads are running from one instance?

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
526
Благодарностей
112
Баллы
43
Hi guys!
We deploy a web based task manager and, at this time, it work only as single thread.

With follow c# code we can get if instance is running or no:
Код:
string ids = "7b4e8688-5235-452c-a9b1-85b503f14ce7";
Guid g = new Guid(ids);
return ZennoPoster.GetTaskInfo(g);
Now I need to see how much active threads that project is running, as example, If I sold to my client a maximum of 5 threads, I want to start maximum 5 threads.

From task list we can retreive a lot of informations but no information about number of running threads:
Код:
<Id>2a267673-1d79-44be-aa36-e213a32b2d5f</Id>
<Name>Stone_SQL</Name>
<IsNewbie>True</IsNewbie>
<IsEnable>True</IsEnable>
<CreateTime>07/13/2018 08:07:16</CreateTime>
<SettingsType>InputSettings</SettingsType>
<ExecutionSettings>
    <Id>a79ce861-e1ef-4c3e-973e-a4ef2282c804</Id>
    <LimitOfThreads>1</LimitOfThreads>
    <MaxAllowOfThreads>0</MaxAllowOfThreads>
    <DoneSuccesfully>8360</DoneSuccesfully>
    <DoneAll>826</DoneAll>
    <NumberOfTries>0</NumberOfTries>
    <LastNumberOfTries>826</LastNumberOfTries>
    <Priority>50</Priority>
    <Proxy>DoNotUseProxy</Proxy>
    <Status>Schedule</Status>
    <ProxyLabels></ProxyLabels>
    <ShouldBeExecutedRandomly>False</ShouldBeExecutedRandomly>
    <GroupLabels>Client118</GroupLabels>
    <GroupStates>Scheduled</GroupStates>
    <MaxNumOfSuccesStop>-1</MaxNumOfSuccesStop>
    <MaxNumOfFailStop>-1</MaxNumOfFailStop>
    <NumOfFailStop>0</NumOfFailStop>
    <ShowTask>False</ShowTask>
    <TraceTask>False</TraceTask>
</ExecutionSettings>
<SchedulerSettings>
    <Id>e487990c-15c7-4a6e-a4ee-a4995ef622ee</Id>
    <StartDate>07/13/2018 08:07:00</StartDate>
    <ShedulerOnDate>07/13/2018 08:07:00</ShedulerOnDate>
    <EndDate>07/13/2019 08:07:00</EndDate>
    <RepetitionCount>1</RepetitionCount>
    <ScheduleType>EveryMinutes</ScheduleType>
    <RepeatType>WithoutEnd</RepeatType>
    <ActivateTime>01/01/0001 00:00:00</ActivateTime>
    <ActivateWorkTime>01/01/0001 00:00:00</ActivateWorkTime>
    <IsActive>True</IsActive>
    <NumberOfTries>1</NumberOfTries>
    <Minutes>15</Minutes>
    <Days>1</Days>
    <LastScheduleDate>11/14/2018 14:37:00</LastScheduleDate>
    <NextScheduleDate>11/14/2018 14:52:00</NextScheduleDate>
    <IsClearSucces>False</IsClearSucces>
    <GroupName></GroupName>
</SchedulerSettings>
<TriggerSettings>
    <Id>f2652d9d-b476-4c0a-af64-0bac06fffabf</Id>
    <CheckFileExistanse>False</CheckFileExistanse>
    <CheckFilePath></CheckFilePath>
    <RemoveCheckFile>True</RemoveCheckFile>
    <NumberOfTries>0</NumberOfTries>
    <IsClearSucces>False</IsClearSucces>
</TriggerSettings>
<Project>
    <ProjectFileLocation>\\192.168.25.141\Taks\L.xmlz</ProjectFileLocation>
    <ProjectType>Assembly</ProjectType>
</Project>
There is any code to retreive number of active threads running in one project.
 
Последнее редактирование:

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
526
Благодарностей
112
Баллы
43
Bump! Bump! Bump!
 

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
526
Благодарностей
112
Баллы
43
Bump bump bump!

Here is the real problema:
I sold 5 simultaneous tasks and set the project to do maximum 5 simultaneous threads.
Client start bot with parameters 1 Task 1 - ZennoPoster start task and add 1 active thread (parameters 1)
Client start bot with parameters 2 Task 2 - ZennoPoster start task and add 1 active thread (parameters 2)
Client start bot with parameters 3 Task 3 - ZennoPoster start task and add 1 active thread (parameters 3)
Client start bot with parameters 4 Task 4 - ZennoPoster start task and add 1 active thread (parameters 4)
Client start bot with parameters 5 Task 5 - ZennoPoster start task and add 1 active thread (parameters 5)
Now I have 5 threads running and the problem start.
Client start bot with parameters 6 Task 6 - ZennoPoster is waiting for thread and add 1 to execution task (parameters 6)
Client start bot with parameters 7 Task 7 - ZennoPoster is waiting for thread and add 1 to execution task (parameters 7)
Client start bot with parameters 8 Task 8 - ZennoPoster is waiting for thread and add 1 to execution task (parameters 8 )
Task 1 completed succesfull.
ZennoPoster start task 6 but use parameters of task 8.
Task 2 completed succesfull.
ZennoPoster start task 7 but use parameters of task 8.
Task 5 completed succesfull.
ZennoPoster start task 8 with last parameters set.

I want to check how much threads are running before start a task, if maximum threads are running, the task 6 must wait another task end before start that.
All threads are started by a BAT file to Zenno Standart (dev tests):
Код:
@echo off
echo Starting task... (-names "timeout /t 1")
"C:\Program Files (x86)\ZennoLab\EN\ZennoPoster Standard\5.16.2.0\Progs\TasksRunner.exe" -o ImportInputSettings \\192.168.0.14\Client745.xml -names "Client745"
timeout /t 1
"C:\Program Files (x86)\ZennoLab\EN\ZennoPoster Standard\5.16.2.0\Progs\TasksRunner.exe" -o SetTries 1 -names "Client745"
timeout /t 1
"C:\Program Files (x86)\ZennoLab\EN\ZennoPoster Standard\5.16.2.0\Progs\TasksRunner.exe" -o StartTask -names "timeout /t 1"
Or Zenno Pro (client projects):
Код:
pushd %~dp0
@echo off
echo Starting task... (-names "Client404")
"C:\Program Files (x86)\ZennoLab\EN\ZennoPoster Pro\5.16.2.0\Progs\TasksRunner.exe" -o ImportInputSettings \\192.168.25.160\Projects\Deploy\Client404.xml -ids "7b4e8688-5235-452c-a9b1-85b503f14ce7"
timeout /t 1
"C:\Program Files (x86)\ZennoLab\EN\ZennoPoster Pro\5.16.2.0\Progs\TasksRunner.exe" -o SetTries 1 -ids "7b4e8688-5235-452c-a9b1-85b503f14ce7"
timeout /t 1
"C:\Program Files (x86)\ZennoLab\EN\ZennoPoster Pro\5.16.2.0\Progs\TasksRunner.exe" -o StartTask -ids "7b4e8688-5235-452c-a9b1-85b503f14ce7"
Example of parameters into a xml file:
Код:
<InputSettings>
   <InputSetting>
     <Name>acessoUsuario</Name>
     <Value>651661321651</Value>
     <OutputVariable>{-Variable.acessoUsuario-}</OutputVariable>
     <Type>Text</Type>
     <Help></Help>
  </InputSetting>
  <InputSetting>
     <Name>acessoSenha</Name>
     <Value>Safqr!1234</Value>
     <OutputVariable>{-Variable.acessoSenha-}</OutputVariable>
     <Type>Text</Type>
     <Help></Help>
  </InputSetting>
  <InputSetting>
     <Name>acessoStatus</Name>
     <Value>1</Value>
     <OutputVariable>{-Variable.acessoStatus-}</OutputVariable>
     <Type>Text</Type>
     <Help></Help>
  </InputSetting>
  <InputSetting>
     <Name>acessoID</Name>
     <Value>404</Value>
     <OutputVariable>{-Variable.acessoID-}</OutputVariable>
      <Type>Text</Type>
      <Help></Help>
   </InputSetting>
</InputSettings>
 
Последнее редактирование:

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
526
Благодарностей
112
Баллы
43
Bump! Bump! Bump!
 

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
526
Благодарностей
112
Баллы
43

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
Hi. Not something You can answer easy and fast.
This is not question about zennoposter, but about logic in your projects.
I have read, it through and understood that there need to understand whole your project before any answer can be given, and thats not fast and easy task.
Hope someone can answer more clear, but I doubt it.

On fast look I can say that You can make Your own file like when thread starts then save some information in file and when it ends then remove that line from file. Then in any step You can count lines appropriate to your project to know how many threads are running at the moment.

Good luck
 
  • Спасибо
Реакции: EtaLasquera

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
526
Благодарностей
112
Баллы
43
I can't control thread execution based on a number inside a file or based into a file existance, sry, this is not corretct.

Since I can retreive status of project inside tag
"<GroupStates>Scheduled</GroupStates>" that can return "stopped" or "running"

My question is about something like this:
"<NumberOfThreads>3</NumberOfThreads>"
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)