|
Who the hell uses RS232 these days?
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
People who don't want to pay for the LAN hardware and protocol stack processing overheads!
Seriously, in embedded computing, you can fit RS232 for a few tens of pence, whereas the connector alone for a network cable can cost twice that before you get to the hardware behind the connector. Particularly when you are talking about low volumes.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
i couldn't find any rfid reader at low cost, with any ither interface...the one with rs232 was the most common one..thats why i sticked to it...will try to understand the tutorial...will atch back i i encounter problems(which i definitely will! )
thnx
|
|
|
|
|
Good luck! (It won't be that bad, honest!)
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
I have developed a windows service (MainService) which monitors the messages sent from other windows services.
The MainService knows which services to monitor by reading The services names from settings.xml file.
At present in the settings.xml, there are several services names i.e. service1, service2, etc... which the MainService reads (using a foreach loop).
As you see below, the code shows how the MainService reads the settings and checks the previous time of the service message...
Question:
Everytime I add a new service name to the setting.xml, I have to duplicate the below code for the new service (But with new related variables i.e. _dtPreviousService?Time), etc ...
How can I make the code dynamic, so that if a new service name is added to the settings.xmml, then I do not have to add/duplicate code just to check the new service?...
Hope you see what I am trying to achieve?
Thank you
The c# code in the MainService is something similar to the following:
_dtPreviousService1Time datetime;
_dtPreviousService2Time datetime;
...
...
foreach(ServerMonitor item in monitorSettings)
{
if (item.Servicename == "service1")
{
if (_dtPreviousService1Time != DateTime.MinValue)
{
TimeSpan span = PresentTime.Subtract(_dtPreviousService1Time);
dblTimeDifference = span.TotalSeconds;
_dtPreviousService1Time = PresentTime;
}
else
{
_dtPreviousService1Time = DateTime.Now;
}
break;
}
elseif (item.Servicename == "service2")
{
...
...
...
}
}
...
...
...
|
|
|
|
|
using a collection/dictionary/list/array of DateTime?
I cannot remember: What did I before google?
|
|
|
|
|
Use a container to which you can add items dynamically. For example, you can use a Dictionary<string,DateTime> . Service names will be keys to this dictionary; values would correspond to your dtPreviousService##Time variables. Documentation is here[^].
|
|
|
|
|
Store the previousServiceTime value in the ServerMonitorClass
"You get that on the big jobs."
|
|
|
|
|
|
Having multiple threads in the application to use the same helper class what is the better approach to code it in terms of performance and thread safety? static or non-static?
There is only one method in class.
static public class Img
{
static public Bitmap Crop(Bitmap image, Rectangle rect)
{
Bitmap cropped = new Bitmap(rect.Width, rect.Height, image.PixelFormat);
using (Graphics g = Graphics.FromImage(cropped))
{
g.DrawImageUnscaledAndClipped(image, rect);
return cropped;
}
}
}
Will the access to image parameter be safe? Each thread has its own image object created and disposed.
Will there be the performance bottleneck in that function?
Чесноков
|
|
|
|
|
According to the docs, Graphics.FromImage[^] is thread-safe (thread safety section is at the bottom of this very long doc). Your code does not have or need explicit locking, so it would not create additional synchronization bottlenecks. However, in the unlikely case that Graphics.FromImage uses explicit synchronization, your code would become a synchronization bottleneck implicitly.
|
|
|
|
|
Are the parameters passed to static Crop() function are also thread safe inside the function body similar to local variables? Bitmap image is a reference type, each thread creates it inside its worker method and passes to Crop() .
Чесноков
|
|
|
|
|
As long as threads do not share instances of Bitmap image (as you indicated), there is no difference between local variables and parameters.
|
|
|
|
|
There should be no problem with your static method as long as it uses the image parameter only for reading purposes. Problems might arise if any other thread of your application is also attempting to write into of this object, remember, the one referenced by the image parameter.
|
|
|
|
|
I'm disturbed about static function reference object parameters thread safety.
Local parameters in the function are safe, they are created for each thread, e.g. cropped image.
2nd parameter is value object Rectangle is also safe, copy is created as you pass it.
1st parameter is reference object Bitmap. There is no writing to that parameter as you can see in the code. There should not be any difference if you modify it either if it is safe.
My question is whether parameters to static function are passed in a thread safe approach?
That is do they have the same thread safety as local variables in that static function body?
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: whether parameters to static function are passed in a thread safe approach?
the question doesn't make sense. there is no such thing as "passing parameters in a thread-safe way".
parameters get handled by the method called, whether it is static or not.
and they exist on behalf of the caller, who could or could not share them with other code on other threads.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
May be I've overworked but having N threads in Crop() function.
cropped is local variable and safe, each thread has its own object created.
Each thread has its own Bitmap passed to Crop() .
Will 1st parameter image in Crop() function when accessed by one of N threads at the same time be refering to its own thread?
Чесноков
|
|
|
|
|
when a reference type is passed to a method (static or not), nothing happens to the object. All that happens is the method is given a way to work with that object.
objects in general don't know about threads, they don't "refer to a thread".
Chesnokov Yuriy wrote: Each thread has its own Bitmap passed to Crop().
So what problem could arise?
you can open 10 distinct documents with MS Word at the same time; they won't interfere with one another; executing the same code on different objects does not cause failure. Only having multiple threads working on the same data may cause problems.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
As far as I know, passing parameters to a static method is not different than passing them to instance ones, I mean, if another thread might be writing the image parameter of your sample, then you should explicitly synchronize the threads to make sure the program will not try to read and write at the same time, becouse in that case your reading operations might read "trash bytes" due to a not finished writing operation.
|
|
|
|
|
hello,
i have been using using Microsoft.Office.Interop.Word in my webserver (yes, i know it is not recommended)
when i ran it on my machine it runs fine but when running on the server i get time out on the line:
Documents.Open //when trying to open the file.
is there something im missing?
is there a better way to edit word document within web servers/ websites? (i can't create a new one using string builder or outputting into file i need to edit an existing one that sits on the server)
any input will be appreciated as I'm stuck on this for few days already...
thanks
|
|
|
|
|
Filepaths.
That is usually the problem, check them before anything else.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
thank you but i already checked that and the file exists...
|
|
|
|
|
Could be a lot of reasons. Security settings: Word creates a ~MyDocucemt.docx file in the directory - has the user write access to that directory.
Or a message box popping up from Word (e.g. confirm conversion, confirm share) - nobody will be able to click OK there...
|
|
|
|
|
Thank you everyone for trying, checked all ideas but it didnt work
thank you anyway
|
|
|
|
|
Hi All,
I want to pass only the single object of
dtoSourece sObj = new dtoSourece(); for xml serialization.
but cannot access sObj.applicant.firstname
Please help me with this?
static void Main(string[] args)
{
dtoSourece sObj = new dtoSourece();
sObj.name = "ram";
sObj.age = "25";
jlvformApplicant s = new jlvformApplicant();
s.firstname = "india";
Console.WriteLine("india=" + sObj.applicant.firstname);//getting error
Console.ReadLine();
}
class dtoSourece
{
public string name { get; set; }
public string age { get; set; }
private jlvformApplicant applicantField;
public jlvformApplicant applicant
{
get
{
return this.applicantField;
}
set
{
this.applicantField = value;
}
}
}
public class jlvformApplicant
{
private string firstnameField;
private string lastnameField;
/// <remarks>
/// <remarks>
public string firstname
{
get
{
return this.firstnameField;
}
set
{
this.firstnameField = value;
}
}
/// <remarks>
public string lastname
{
get
{
return this.lastnameField;
}
set
{
this.lastnameField = value;
}
}
}
Ramkumar
("When you build bridges you can keep crossing them. ")
http://ramkumarishere.blogspot.com
|
|
|
|