What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Multiplethread error when disconnect Need help

GomuGomu

Member
Joined
Nov 9, 2014
Messages
57
Reaction score
0
I have problem when run code with Multiplethread after disconnect it's show some error like this.

QZnFwC7.png


This is my example code with error when disconnect and need help T-T

public void PluginRun()
{
Thread thread = new Thread(test);
Thread thread2 = new Thread(test2);
thread.Start();
thread2.Start();

while (true)
{
//bla bla bla
//.
//..
//...
}
}

private void test()
{
while (true)
{
Log("thread 1");
Thread.Sleep(1000);
}
}

private void test2()
{
while (true)
{
Log("thread 2");
Thread.Sleep(1000);
}
}

If anyone know how to fix this problem please show me some example I'm still beginner in programing, Thank you.
 
Thanks for answer.
I try change private to public but still have same error T-T
(test by stop account while running plugin)
 
Thanks for answer.
I try change private to public but still have same error T-T
(test by stop account while running plugin)

Brutal variant:
Add to PluginStop()
PHP:
thread.Abort();
thread2.Abort();

Correct variant:
Add a requestStop bool, change it in PluginStop and check it before using any marshalled obj. And perform isExist() checks for this objects.
 
Brutal variant:
Add to PluginStop()
PHP:
thread.Abort();
thread2.Abort();

Correct variant:
Add a requestStop bool, change it in PluginStop and check it before using any marshalled obj. And perform isExist() checks for this objects.
Пользуясь случаем хотел бы спросить по похожей проблеме.
У меня тоже есть потоки и управляющая переменная.
Как только она становится true, циклы в потоках останавливаются и потоки завершаются.
Но вот бывает такая беда:
Внезапно по логам я вижу, что все потоки завершили свою работу.
Однако, PluginRun и PluginStop не завершались (не срабатывает финальный отладочный Log()).
Плагин при этом останавливается.
В менеджере плагинов он виден как не запущенный.
И невозможно запустить ни его, ни какой-либо другой плагин - не нажимается кнопка запуска.
Лечится только перезапуском АВ, котрый падает при закрытии.

Как можно отловить причину такой проблемы?
И никак не могу понять, как потоки могут самопроизвольно завершаться, если управляющую переменную никто не трогает.
То есть они не зависают/падают, а именно нормально завершаются.
Но даже если она внезапно стала true, то тогда должен завершиться и основной цикл в PluginRun и плагин должен штатно остановиться.
При этом, когда я сам присваюваю значение true управляющей переменной, всё нормально завершается.
 
Last edited:
Думаю, Вы не совсем верно описываете проблему.
Я бы предположил, что критуется ядро. В этом случае ни один из описанных Вами способов диагностики не сработает.
Косвенно об этом говорит то, что окно плагинов у вас перестает отвечать.
Пробуйте логировать не методами АБ, а напрямую, для начала.
 
Brutal variant:
Add to PluginStop()
PHP:
thread.Abort();
thread2.Abort();

Correct variant:
Add a requestStop bool, change it in PluginStop and check it before using any marshalled obj. And perform isExist() checks for this objects.


I put this code in PluginStop but still error when disconnect

thread.Abort();
thread2.Abort();

I have read in another thread related with this case

https://www.thebuddyforum.com/archeb...ork-crash.html

But I'm still beginner don't know about boolean marshalled obj or perform isExist() to check object.

Could you please give me an example for exception this error ?

Thank you.
 
PHP:
if (isExist(obj)) dosomething.
But this method good for 1-point check, if you use marshaled objects in whole code, you must make error handling.
Use try-catch for founding place, where your errors generates.

And at first make your threads background and test.
 
PHP:
if (isExist(obj)) dosomething.
But this method good for 1-point check, if you use marshaled objects in whole code, you must make error handling.
Use try-catch for founding place, where your errors generates.

And at first make your threads background and test.

error CS0103: The name 'isExist' does not exist in the current context

I'm very noob in programming and still not understand :(

Can you write full code to solve my code problem above ? Please T-T
 
Back
Top