I'm using a System.Timers.Timer to send some data to a serial port every so often. Problem is, if the main thread gets tied up, with internal processing, or hitting a breakpoint for example. A long queue of events gets queued up, then once the app is back in business, all of the messages get handled almost simultaniously. I've tried to come up with a work around, but I'm stumped, any suggestions. Thanks, sam
sammyh
Posts
-
Timer message queue -
display row number in datagrid?DataGrid is such an awkward control, a major pain if you ask me. I'm looking forward to using .NET 2.0. Any tips to get me in the right direction. Or should I opt for a 3rd party control? Thanks, Sam
-
display row number in datagrid?What would be the best way to display row numbers in a datagrid? Simply 1,2,3,4,5, etc. Thanks for any help. -Sam
-
"open with"...Exactly what I was looking for, thanks
-
"open with"...Sweet, that shows how to link an extension to the application, set the icon for the extension, and extend the shell, but... How do I handle the link in my app? Do I need to test for a registry entry, is the program called with arguments, do I override function? I can't find anything on this subject. Thanks again for the help. -Sam
//you know you've been coding for too long when you hit Ctrl-Shift-B instead of submit
-
"open with"...Could someone please point me to some info on the how to make my app open a file when it is double clicked in explorer. Thank you, Sam
-
Calling a class exported by a custom DLL in C#If it where me, I would create a wrapper in Managed C++, then call that from c#. That way you could totally avoid DllImports. DllImports is fine and dandy for most functions, especially win32, but once you hit a function with some off the wall data structure it turns into a pain real quick. -Sam
-
Import a "C" function that returns a struct...I have a .dll with "C" functions that I need to call. One of the functions returns a simple struct(2 doubles) If I try to use DllImport like this:
[ DllImport("somedll.dll] SomeStruct1 f1(SomeStruct1 *pS);
I get compiler error C3385 "a function that has a DllImport Custom Attribute cannot return an instance of a class" How can I import a function from a DLL that returns a struct??? Thanks a ton, Sam -
need to import weird C structalright... progress, seems to be working The last 2 hurdles First I was doing this
[StructLayout(LayoutKind.Sequential)] public class paralist { paralist next; char used; char param; }
when it likes this better[StructLayout(LayoutKind.Sequential)] public unsafe class paralist { paralist *next; char used; char param; }
Second, I had to replacefwd fwdcallback;
withint fwdcallback;
Thanks again. -
need to import weird C structI'm still having problems with the marshalling I get an exception "Can not marshal field param of type ProjWrapper.PJ: The type definition of this field has no layout information." I have tagged it with Layout.Sequential
//XY (*fwd)(LP, struct PJconsts *); original public delegate XY fwd(LP lp, PJ pj); ///etc [StructLayout(LayoutKind.Sequential)] public class PJ { fwd fwdcallback; //etc }
Could the problem be in the return Marshal of the PJ class, or am I messing up the callback definitions still Thank you very much for your help.... -Sam -
need to import weird C structYeah XY and LP are easy, my problem is the PJconsts struct..... which is really the PJ struct, I think the PJconsts is some type of C label, while PJ is the actual name. This thread http://forums.devshed.com/archive/42/2003/9/1/80923 talks a bit about it... and what is the deal with the first 4 lines of the struct.....
-
how do i enable directx?You should start by opening some samples and playing with them... If everything is installed right, you should just be able to click Project->Add Reference, and they should be under the .NET tab. The dlls are in C:\WINDOWS\Microsoft.NET\Managed DirectX if you need to do a direct reference
-
need to import weird C structI am trying to import some functions from an open source library(DLL). //Here is the function definition in C/C++ PJ* pj_init(int argc, char **argv); //Here is the PJ struct in a .h file typedef struct PJconsts { XY (*fwd)(LP, struct PJconsts *); LP (*inv)(XY, struct PJconsts *); void (*spc)(LP, struct PJconsts *, struct FACTORS *); void (*pfree)(struct PJconsts *); const char *descr; paralist *params; /* parameter list */ int over; /* over-range flag */ int geoc; /* geocentric latitude flag */ int is_latlong; /* proj=latlong ... not really a projection at all */ int is_geocent; /* proj=geocent ... not really a projection at all */ double a, /* major axis or radius if es==0 */ e, /* eccentricity */ es, /* e ^ 2 */ ra, /* 1/A */ one_es, /* 1 - e^2 */ rone_es, /* 1/one_es */ lam0, phi0, /* central longitude, latitude */ x0, y0, /* easting and northing */ k0, /* general scaling factor */ to_meter, fr_meter; /* cartesian scaling */ int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */ double datum_params[7]; double from_greenwich; /* prime meridian offset (in radians) */ #ifdef PROJ_PARMS__ PROJ_PARMS__ #endif /* end of optional extensions */ } PJ; I understand that I need to use DLLImport to import the function and [ StructLayout( LayoutKind.Sequential )] to create a clss representing the struct, but I'm clueless on the first 4 lines in the struct above: XY (*fwd)(LP, struct PJconsts *); LP (*inv)(XY, struct PJconsts *); void (*spc)(LP, struct PJconsts *, struct FACTORS *); void (*pfree)(struct PJconsts *); XY and LP are simple structs typedef struct { double x, y; } XY; typedef struct { double lam, phi; } LP; Any ideas? Thanks, sam
-
electronic bookssafari.oreilly.com is a online book program, you can browse books for free, but must pay a monthly fee for your "bookshelf". They have alot on .NET, but not much on mathematics, and nothing on GPS. Is there anything specific you need to know about GPS, I've done my share of research on the topic...
-
ToDouble problemA double is a double precision floating point number. Floating point numbers can't always represent a number perfectly. If you need better accuracy, there is the Decimal data type (But it is VERY slow compared to double) Beginning of this article talks a bit about it http://tom.cs.byu.edu/~557/text/ch14.pdf
-
Interface? Abstract? DLL? Component? please helpI am creating an app, that needs numerous "drivers" the "drivers" are simple components that will accept a string, parse it and change some data in the main app. I want to be able to load all of the drivers from a directory at run-time. So I can just place a new one in the directory and run the app without re-compiling. Could someone please point me in the right direction. I am assuming each would go into their own DLL and be based on either an interface or a base class. But I still can't see the big picture and how they would load at run-time, or how they would fit into the main app. Thank you very much for any help.
-
precision problems with double typeOK, When you create a directx device it changes all operations to single precision. It can be overridden with the fpupreserve flag. Thanks for the help. -Sam
-
precision problems with double typeThis snippet:
decimal px = -10.335927963256836M; decimal ix = 12589230.0342M; decimal nx= px + ix; double d = Convert.ToDouble(nx); double c = 2;
Works as long as it happens before this line: device = new Device(graphicsSettings.AdapterOrdinal, graphicsSettings.DevType, windowed ? ourRenderTarget : this , createFlags, presentParams); If it happens the line after I get my problem.... now that is messed up, how can it change the behavior of a built in type???? -
precision problems with double typeYOU'RE right!!!!! Now that makes things even weirder.... My actual code.... public void Translate(double x, double y, double z) { foreach(DPoint p in points) { p.x += x; p.y += y; p.z += z; } } a Dpoint is just 3 doubles x,y,z on the first iteration of the foreach: x=12589230.0342 y = 693719.8863 z = 0.0 p.x = -10.335927963256836 p.y = 9.6102085113525391 p.z = 5.7499995231628418 after first iteration p.x = 12589220.0 p.y = 693729.5 p.z = 5.7499995231628418 I'm trying to replicate problem is a simple app now...
-
precision problems with double typeI'm having precision problems with the double type, the help files say I should get 15 digits of precision... BUT...
double d1 = 12589230.0342; double d2 = -10.335927963256836; //good precision, but when added, problems occur double newd = d1+d2; // newd now equals 12589220.0
Where's all my precision???? I've tried decimal type, but is's incredibly slow.... I have to use it when multiplying, but addition of 10??? Any suggestions? should I use my own type? Possibly a binary coded decimal Thanks for any help. -Sam