Programming
-
Calling Delphi 6 DLL from c#.NET and blasted rounding issues
Recently I had the need to call a Delphi DLL from a .NET application. The delphi DLL would be performing a number of floating point arithmetic operations and returning results in as a string. In order to debug the delphi DLL another delphi application was written that uses this same interface and outputs the results. The problem I started experiencing was that the results produced when calling from my c# application varied from those called from the delphi application. Both used the same DLL and both produced the same inputs. I don’t have much in-depth knowledge about floating point numbers but I have read enough to know that most of…
-
Thread safe logging to file using Java
In an attempt to create a simple logging class for a Java socket server application I was writing I wanted to make sure that the class captured all log events from the various threads sending messages to it. I didn’t want to have the situation where some messages were lost because the class could not handle the log messages being sent to it. In order to do this I decided to use a Consumer – Producer concept. Thankfully in Java this concept has already been thought of via the use of java.util.concurrent.BlockingQueue. The set of classes available for use with this include DelayQueue PriorityBlockingQueue SynchronousQueue ArrayBlockingQueue LinkedBlockingQueue From various readings…
-
Showing Enums in a dropdownlist on our ASP.NET MVC view
A little while ago I posted a discussion on a method to decorate Enums with attributes to provide some flexibility with how they are displayed. Background This came about in a project I worked on where we wanted to show user friendly names of an enumeration on a Web UI page, but the same Enum was to be serialized to XML using a different set of names. Most articles concentrated on decorating an Enum with one attribute. We needed two, and wanted the ability to set which of those two took precedence in different scenarios. The code Here, I’m showing an implementation on how you could use that functionality to…
-
Posting content from memory stream using HttpWebRequest c#
So I needed to upload a zipped file that I was creating in memory and send it to an MVC action on my server. I read plenty of examples and perhaps I could have gone down the route of saving the stream to a file on disk and then using the .net WebClient UploadFile method. But I didn’t and so I’ve ended up with a class based off a number of help from various parties including an excellent example at . A very good place to find the specification on what is needed is at . I found this helped alto and explained some of the missing pieces of information…