| | |
managing object in callback
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
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 alignment app application array bitmap box c# c#gridviewcolumn check checkbox client color combo combobox communication concurrency control conversion csharp custom data database datagrid datagridview dataset datatable datetime degrees draganddrop drawing enabled encryption enum excel file focus form format forms function gdi+ getoutlookcontactusinfcsvfile globalization hospitalmanagementsystem image input install java label list localization mandelbrot math messagebox microsoftc#visualexpress mono mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics string stringformatting sun table text textbox thread time timer update usercontrol validate validation visualstudio webbrowser whileloop winforms wpf xml





