Search Unity

External DLLs interrupt Unity

Discussion in 'Scripting' started by shaun, Jun 18, 2007.

  1. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    We are using the MAPIEx.dll to convert some data into XML via Unity - it works fine, but the problem is that Unity completely freezes when this process is running (which can take up to a minute).

    I did post about this before, but didn't get much of a response~ I was wondering what others are doing when using external DLL's? Ive tried Co-routines which don't seem to work. I know we can use multi-threading, but I'm not sure about that via p-invoke for unmanaged code and if this is even a good idea in Unity.

    Some feedback from OTEE or someone else who's hit this problem before would be great...thanks! :D

    Shaun
     
  2. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104
    Coroutines won't work for this, because they're not threads.

    I can't see why carefully using threads for this shouldn't work. Especially if you make sure you don't call into the same library more than once at the same time (at least unless it's re-entrant).

    d.
     
  3. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    Thx David - Will look into running the processes in a different thread.

    When we invoke the DLL, it's obviously running on a PC client (as there is no MAPI on Mac). I'm not sure I understand correctly, but is Mono still being used by Unity when running on PC, or are we running on native .Net? (and if so, can we use .Net2 for platform specific C# scripts? - i.e. ones that will never be run on a Mac)
     
  4. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104
    Unity uses Mono on both platforms.

    d.