Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

Multiple Threads

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

Post Reply
dragon_chichi

Multiple Threads

Post by dragon_chichi » 18 Jan 2012, 12:33

Hello
How i can make a separate Thread from inside Ventuz (i.e. in my Ventuz Script node). I need read data from Excel (many difference data so workbook node isn't suited). If does it without separate Thread the Scene is hanging. Here is my code:

public bool OnUpdate(int arg)
{
Thread ExcelThread = new Thread(new ThreadStart(this.MyThread));
ExcelThread.Start();
return false;
}

public void MyThread()
{
try
{
app = new Excel.Application();
Update_Info = "OK";
s = "AlbumInit";
AlbumInit();
s = "ReadConfig";
ReadConfig();
s = "LoadItems";
LoadItems();
s = "Output_Current_Upgrade";
Output_Current_Upgrade();
test_size = "photo: " + Photo.AlbumQnt.ToString() + "video: " + Video.AlbumQnt.ToString() + "mesh: " + Mesh.AlbumQnt.ToString() + "audio: " + Audio.AlbumQnt.ToString();
changed = true;
s = "finish";
}
catch
{
Update_Info = "There are some errors";
}
finally
{
app.Quit();
app = null;
book = null;
sheets = null;
sheet = null;
cell = null;
}
}

Methods MyThread( ) and OnUpdate( ) ReadConfig( ) etc are members of Script class. Functions like ReadConfig( ), LoadItems( ) are my function which is worked well. In the issue Ventuz has crashed with: (System.NullReferenceException) in "Ventuz.exe [8296]".

User avatar
Ralf Stanke
Posts: 11
Joined: 10 Jan 2012, 12:03

Re: Multiple Threads

Post by Ralf Stanke » 18 Jan 2012, 19:34

Hi, I can't realy say what is wrong in your script - so I'm just guessing:
  • Ensure that you do not update any script properties from that extra thread. Store the actual results in member varibales and mark them as NEW. The GenerateValues method should see the updated data and transfer it to the output properties in the main thread. (don't forget to return true, to let Ventuz know about the new values)
  • Try to enabled the Debugging mode to figure out what goes wrong. See user manual (you'll need a Visual Studio installed)
    http://www.ventuz.com/support/help/late ... alDebugger
Best regards and good luck
Ralf

joschy
Posts: 142
Joined: 19 Jan 2012, 07:39
Location: Düsseldorf, Germany
Contact:

Re: Multiple Threads

Post by joschy » 19 Jan 2012, 07:48

Hi,
for exel stuff I use a this:

http://www.gemboxsoftware.com/spreadsheet/free-version

The free version of a C# library, very useful. May be it help.

greatings
3DJo - [Ventuz] freelancer and trainer

joschy
Posts: 142
Joined: 19 Jan 2012, 07:39
Location: Düsseldorf, Germany
Contact:

Re: Multiple Threads

Post by joschy » 19 Jan 2012, 07:53

For exel stuff I use this:

http://www.gemboxsoftware.com/spreadsheet/free-version

Nice free C# library

joschy
3DJo - [Ventuz] freelancer and trainer

dragon_chichi

Re: Multiple Threads

Post by dragon_chichi » 23 Jan 2012, 07:54

Big thanks!!!
The problem was I updated Script properties:) I deleted line "changed = true;" from end of TRY block in MyThread() and it got worked. But now i dont undestand why?? Inside my Output_Current_Upgrade() function i have line "changed = true;". Does Ventuz ignore it???

Sorry maybe it is foolish questions but: (1) How "mark them as NEW"???
(2)How call the "GenerateValues method"?

Post Reply