| | |
managing object in callback
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 1
Reputation:
Solved Threads: 0
I have a program that gets callback from an external program. It sends back a type object[] that is of variable length. I want to take the parts of the object[] and put them into native data types (int). In the callback, I get an object called 'ObjectOfIntegers'. It has a built in method (from the third party application called 'get'. 'get' returns an object[] that has all the things i ask for. The third party program's 'get' function obviously is the barrier. so it looks something like this:
ObjectOfIntegers.get("Integer1,Integer2")
or it could be
ObjectOfIntegers.get("Integer1,String1")
If I know I am getting integers, I want to be able to put them in native data types and then use them (ie put them in myInteger1, myIntegery2, myString1, etc). so i declare the integers and strings globally and then want their assignment to be done in the callback. i've tried these two ways:
1)
private int[] intArraySize2 = new int[2];
private int myInteger1, myInteger2;
private void someCallbackFunction(ThirdPartyDataType ObjectOfIntegers)
{
Array.Copy(((Array)ObjectOfIntegers.get_Get("Integer1,Integer2")), intArraySize2, 2);
myInteger1= intArraySize2[0];
myInteger2= intArraySize2[1];
}
2)
private Object[] dataObject = null;
private int myInteger1, myInteger2;
private void someCallbackFunction(ThirdPartyDataType ObjectOfIntegers)
{
dataObject = (Object[])ObjectOfIntegers.get_Get("Integer1,Integer2");
myInteger1= (int)dataObject.GetValue(0);
myInteger2= (int)dataObject.GetValue(1);
}
Does anyone know which would be faster? Is there a better way to handle this? Speed is the most important issue to me. If anyone has any ideas of what to do, how to do it faster, or where to go for more information I would REALLY appreciate it. Thanks so much.
ObjectOfIntegers.get("Integer1,Integer2")
or it could be
ObjectOfIntegers.get("Integer1,String1")
If I know I am getting integers, I want to be able to put them in native data types and then use them (ie put them in myInteger1, myIntegery2, myString1, etc). so i declare the integers and strings globally and then want their assignment to be done in the callback. i've tried these two ways:
1)
private int[] intArraySize2 = new int[2];
private int myInteger1, myInteger2;
private void someCallbackFunction(ThirdPartyDataType ObjectOfIntegers)
{
Array.Copy(((Array)ObjectOfIntegers.get_Get("Integer1,Integer2")), intArraySize2, 2);
myInteger1= intArraySize2[0];
myInteger2= intArraySize2[1];
}
2)
private Object[] dataObject = null;
private int myInteger1, myInteger2;
private void someCallbackFunction(ThirdPartyDataType ObjectOfIntegers)
{
dataObject = (Object[])ObjectOfIntegers.get_Get("Integer1,Integer2");
myInteger1= (int)dataObject.GetValue(0);
myInteger2= (int)dataObject.GetValue(1);
}
Does anyone know which would be faster? Is there a better way to handle this? Speed is the most important issue to me. If anyone has any ideas of what to do, how to do it faster, or where to go for more information I would REALLY appreciate it. Thanks so much.
![]() |
Other Threads in the C# Forum
- Previous Thread: Window Timer in a new Thread
- Next Thread: Open and Close Winform
| Thread Tools | Search this Thread |
.net access algorithm angle array asp.net barchart bitmap box broadcast c# capturing check checkbox client combobox control conversion csharp custom database datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum eventhandlers excel file firefox form format forms function gdi+ image index input install java label leak libraries list listbox loop mandelbrot math monodevelop mouseclick msword mysql operator path pause photoshop picturebox pixelinversion post programming radians regex remoting resourcefile richtextbox round server sleep socket sql statistics stream string table tcpclientchannel text textbox thread time timer update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml





