Multiple Threads
Posted: 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]".
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]".