Well, what I basically recommend using StreamWriter, StreamReader class to write to file /read from the file data stored in your objects. The approach requires specifying format of the file and how pieces of the data stored / retrieved from the file. When applied to your example is might look something like this <code> using System; using System.Collections.Generic; using System.Text; using System.Runtime.Serialization; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Diagnostics; namespace ConsoleApplication1 { public class CTempClass { public int m_uCrc64; public int M_uCrc64 { get { return m_uCrc64; } set { m_uCrc64 = value; } } public CTempClass() { m_uCrc64 = 0; } } class Program { static void Main(string[] args) { List<CTempClass> lsTemp = new List<CTempClass>(); for (int i = 0; i < 1000000; i++) {
Ilia Blank
Posts
-
Deserializing Generic List<object> taking a lot of time</object> -
Deserializing Generic List<object> taking a lot of time</object>You won’t be able to improve significantly performance while using .Net built in serializers. They are inheritably slow. I bumped into this many times. If performance is an issue I would recommend considering implementing custom destabilization (another word for “read you file and parse data in you code”).
-
MultiThread and File processSounds as horse position is embedded inside com3 message. Am I right?
-
MultiThread and File processSorry, I failed to understand last statement. You indicated that you use com3 event to drive “real time” animation. Can you provide more details?
-
MultiThread and File processAssuming that you have three files with full history of the race for each horse from start to finish and you are requested to create animation that simulates the race while preserving proper timing of the race. That what I would do 1. Load each file into corresponding list. Each list element represents position of the horse and timing of this position. Each list is sorted by time. 2. Merge three arrays into one list. Each list element represent time and position of all three horses at this time. The list is sorted by time. 3. Develop UI control that is capable of painting one race frame based on individual element from array created on step 2. Development of such control might be challenging but in general you have to assure that method called to draw particular frame “HorseRaceArenaControl::DrawRaceFrame (horse1Position, horse2Position, horse3Position ) “ can be called from arbitrary thread. The topics that you have to explore are Control::Invoke, Control::OnPaint, “implementing own-drown control”, 4. To call DrawRaceFrame method for each element in the list created in step 2. The method has to be called with time intervals as recorded in each element. You can use .Net System.Threading.Timer class to assure proper timing. I realize that this is not detailed instruction but rather general guidelines. Hopefully it can serve as starting point.
-
MultiThread and File processCorrect me if I am wrong, in both cases the files will contain full history of the race for given horse. For example: 0 milliseconds 0 meters 2 milliseconds 0.3 meters 8 milliseconds 0.8 meters 12 milliseconds 1.1 meters … 88354 milliseconds 2000 meters //Finish
-
MultiThread and File processHow the drawing is initiated? For example: I have to update my animation when one of the files is updated on the disk. Or I have to update my animation with specific time intervals.
-
MultiThread and File processCan you provide more details?
-
Interrogating objects passed from COMYou can use oleview.exe to explore COM types registered on your computer. I assume that you know at least name of the COM type that is passed to your assembly. Use the name to look for the type inside oleview.exe.
-
What’s wrong with “Race condition” in India???
-
What’s wrong with “Race condition” in India?To all developers from India We are interviewing candidates for programming position in Hyderabad India. None of them is able to answer question "What is Race Condition". Can it be that you are using different term in India? Regards
-
Trace implementation for static methods.Hi, My C# code calls to bunch of external methods exported from gdi32.dll That’s example of the code we use to export the methods from the dll:
[DllImport("gdi32.dll")] internal static extern int ExtEscape(HDC hDC, int nEscape, int inputSize, ref CWDDECMD InputData, int outputSize, ref CIWSINFO OutputData); … [DllImport("gdi32.dll")] internal static extern int ExtEscape(HDC hDC, int nEscape, int inputSize, ref CWDDECMD InputData, int outputSize, ref CIOVLTHEATERMODE OutputData);
There are over two hundred of method declarations and they are different only by type of parameters (ie CIWSINFO versus CIOVLTHEATERMODE in this examle). The methods are called from all around the code. Now I have to come with design that allows tracing calls to the methods While printing the name of the method and type and values of passed parameters (this part is simple as each passed type implements ToString method). I just hate idea of duplicating each declaration with the method that performs tracing before calling to real method:[DllImport("gdi32.dll")] internal static extern int ExtEscape(…); static int ExtEscapeTrace (…) { DoTrace (); ExtEscape (…) ; //Perform real call }
To bad the methods are static; otherwise I would be able to use proxies. Any ideas? -
Define a namespace for the WebPage in .NET 2.0Is it possible to define a namespace for the web page, that does not have a separate code-behind class? If yes, how?
-
"Unadvising" Event Sink in VB6I have COM object written in C# that exposes connection points and deployed as out of process server. I wrote VB6 application that supplies handler for the events fired by this COM object. To do that I added reference in my VB project to type library generated for C# COM. Next I used WithEvents statement in my VB code to declare variable of the events firing type exported from the COM. The application works fine. I can consume the events from the C# COM in my VB6 code. Problem arises when I stop my VB application. The delegate that implements the event in C# remains assigned and exception is thrown when attempt is made to call it. When you implement Event Sink say in C++ you use Advise – Unadvise paradigm to assign and clean up your handlers. What you supposed to do in VB6? Any help will be appreciated.
-
"Unadvising" Event Sink in VB6I have COM object written in C# that exposes connection points and deployed as out of process server. I wrote VB6 application that supplies handler for the events fired by this COM object. To do that I added reference in my VB project to type library generated for C# COM. Next I used WithEvents statement in my VB code to declare variable of the events firing type exported from the COM. The application works fine. I can consume the events from the C# COM in my VB6 code. Problem arises when I stop my VB application. The delegate that implements the event in C# remains assigned and exception is thrown when attempt is made to call it. When you implement Event Sink say in C++ you use Advise – Unadvise paradigm to assign and clean up your handlers. What you supposed to do in VB6? Any help will be appreciated.
-
"Unadvising" Event sink in VB6I have COM object written in C# that exposes connection points and deployed as out of process server. I wrote VB6 application that supplies handler for the events fired by this COM object. To do that I added reference in my VB project to type library generated for C# COM. Next I used WithEvents statement in my VB code to declare variable of the events firing type exported from the COM. The application works fine. I can consume the events from the C# COM in my VB6 code. Problem arises when I stop my VB application. The delegate that implements the event in C# remains assigned and exception is thrown when attempt is made to call it. When you implement Event Sink say in C++ you use Advise – Unadvise paradigm to assign and clean up your handlers. What you supposed to do in VB6? Any help will be appreciated.
-
Compressing directrory tree into single zip fileWhat is a best approach for compressing directories structure witch contains multipile files into single zip file using c#.
-
key down in windows forms (C# 2.0) [modified]It will work only if the the form captured the input. As far as I unerstand the goal is to catch all keyborad key downs regardless to the current window.
-
key down in windows forms (C# 2.0) [modified]You can read about windows hooks in .Net here http://msdn.microsoft.com/msdnmag/issues/02/10/CuttingEdge/[^] Use WH_KEYBOARD when installing the hook procedure with SetWindowsHookEx Use following code to detect key down in your hook static readonly int WM_KEYDOWN = 256, public Int32 KeyboardProc(int code, Int32 wParam, Int32 lParam) { if ((Int32)wParam == (Int32)WM_KEYDOWN ) { // do processing } // do not forget to call next hook !!!!!!!!!!!! // CallNextHookEx is win32 api that can be loaded to .Net // using dll import like they did with setwindowshookex in example return CallNextHookEx(hHook, code, wParam, lParam); }
-
key down in windows forms (C# 2.0) [modified]You have to install windows hook procedure to intercept all keyboard events. Look at “How can I use 'Hooks' in .NET” article at following link http://72.14.203.104/search?q=cache:NUhXDPTnLJgJ:www.syncfusion.com/FAQ/WindowsForms/FAQ\_c70c.aspx+"DllImport"+SetWindowsHookEx+WH\_KEYBOARD+C%23&hl=en&gl=ca&ct=clnk&cd=1