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

WPF plugin dll.

Out

Active Member
Joined
Jun 2, 2012
Messages
2,972
Reaction score
13
I dont know, whether it is to anyone, except for one person who asked me.

Code:
private bool _cancelRequested = false;
bool cancelRequested
{
  get
  { return _cancelRequested; }
  set
  {
    _cancelRequested = value;
   }
}
Main mainForm;
Thread formThread { get; set; }
public void PluginRun()
{
  formThread = new Thread(() =>
  {
    try
    {
      mainForm = new Main();
      mainForm.Show();
      Dispatcher.Run();
    }
    catch (Exception error)
    {
      Log(error.ToString());
    }
  });
  formThread.SetApartmentState(ApartmentState.STA);
  formThread.Start();
  while (!cancelRequested)
    Thread.Sleep(10);
}

public void PluginStop()
{
  cancelRequested = true;
  try
  {
    if (mainForm != null)
    {
      mainForm.Dispatcher.InvokeShutdown();
    }
  }
  catch { }
  try
  {
    formThread.Abort();
  }
  catch { }
}
 
Last edited:
WPF - Windows Presentation Foundation.
This is "new" version of Windows Forms.
 
like a multi-client plugin? i am still trying to figure out how to multi-client since i cannot get my AB working on my 2nd pc, even after reinstalling the .net framework and removing previous verion
 
Its not working... when i put it in plugins folder, i go to the plugin menu and its not there, then i go to plugin editor, try to compile it, and it crashes.... =x
we really cant use multi client with archbuddy?
 
Out, i'm experimenting WPF and i admit i like it (i'm a amateur coder that learnt c# recently so instead of dig windows Form i decided for the future...WPF).

Everything work great for now, and i'm learning my way through, but there is this problem, when i stop my plugin (with the AB interface) i can't replace the dll of my plugin until i don't stop AB... it's like there is a thread or something that continue looping and keep something alive.


I use your example, and in the windows1.xalm.cs i add a thread to do my work and update my ui(with a reference to core), nothing more.

That probably what you were mentioning in your post, have you any suggest to give to try to close it the proper way?

Tnx and hope you find this post :)

/hat
 
Last edited:
have you any suggest to give to try to close it the proper way?

try put this after mainForm.Show(); in RunForm method

Code:
mainForm.Closed += (sender2, e2) =>
{
     if (mainForm != null) mainForm.Dispatcher.InvokeShutdown();
};
 
Если сначала закрыть окно плагина и потом стопнуть - то все ок. Если не закрывать окно и сразу стопнуть плагин - вылезает ошибка "COM object that has been separated from its underlying RCW cannot be used". Где копать?
 
Обработай в цикле плагина threadabortexception
А можно пример как это сделать ? У меня тоже проблема с wpf, не могу понять как правильно остановить плагин, не до конца выгружается, как будто какие то объекты остаются в памяти после стопа плагина =(
 
А можно пример как это сделать ? У меня тоже проблема с wpf, не могу понять как правильно остановить плагин, не до конца выгружается, как будто какие то объекты остаются в памяти после стопа плагина =(

Hi friend. I also had the problem with the DLL not unloading after running the first time. Try setting the thread as a background thread.

Code:
formThread.IsBackground = true;

This solved my problem, I hope it helps.
 
Back
Top