|
Any shared resource that is read-only (that is, no threads are writing to the resource) is inherently thread safe. So unless you've got another thread writing to the settings, yes, 2 background threads reading the settings is safe.
|
|
|
|
|
Hi.
Thanks for your reply.
Regards
|
|
|
|
|
My application accepts single string databaseaddress.
I think the best form for this is
servername:port/databasename
parts other than servername may be missing. So legal forms are also
servername
servername:port
servername/databasename
samples:
143.44.454.45:33/mydb
myhost@mycomp.com
myhost@mycomp.com/mydb
How to extract servername, port and databasename to separate variables ?
servername, port and databasename does not contain : and / characters.
There is no need for syntax check.
|
|
|
|
|
I think System.Uri.TryCreate method will work for you.
|
|
|
|
|
i am working on a Point of sales application in C#. I want to redirect the values to the pos device connected to LPT1. Can anyone tell me how i can do this.
Thanks for your help
Regards
Hari
rkharikrishnan.bizhat.com
|
|
|
|
|
Isn't LPT1: just printing it?
|
|
|
|
|
You can connect arbitary devices to the parallel port, not just old printers.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Of course you can. I remember the old ZIP drives that hooked up to the parallel port and took forever to read and write.
My message seemed to be truncated (or I just forgot to hit update ). My point is that when you connect a device to the port, it will need some kind of driver. Then you can interface with that driver.
|
|
|
|
|
VS05 provides a class for the parallel port. IIRC it's in the system.io.ports namespace that should allow you to write to it. If you're using VS02 or 03, you'll have to google up a 3rd party implementation. Try the articles here as a starting point.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Thanks for the reply. i tried using system.io.ports namespace. But its showing only serial ports data. What should i do to send to both com1 and LPT1 ports? How can i check whether it is open?
Regards
Hari
|
|
|
|
|
I developed an Add-in for Outlook 2003 with Visual Studio 2005 Team Suite.
My solution was created via:
Other Project Types -> Extensibility -> Shared Add-in
And I selected support for Microsoft Outlook.
Question 1:
I uncheched all the "Exclude" option of the assemblies in the Setup Project and builded it successfully.
The Add-in installed and ran well in another computer which had also VS 2005 Team Suite on it. However, on a third computer, which only had .NET Framework 2.0 but not VS 2005, the Add-in installed normally but did not load when Outlook started. What's the problem?
Question 2:
My CommandBarButton runs only a few times.
I added a CommandBarPopup to the Main Menu and then added a MsoControlType.msoControlButton to the popup. In the ClickEventHandler of the button, a Windows Form object is created and shown.
The problem is, each time I start Outlook, the button is available for only a few times, usually 2-3 times, sometimes only once. Afterwards it becomes unavailable at all. It gives no response when I click it.
Some of the codes are as follows:
//Acquire the "Menu Bar" and create a new control on it
menuBar = ((Outlook.Application)applicationObject).ActiveExplorer().CommandBars["Menu Bar"];
commandBarControl_CM = menuBar.Controls.Add(MsoControlType.msoControlPopup, 1, "", 6, true);
commandBarControl_CM.Visible = true;
commandBarControl_CM.Caption = "Sychronization";
//Add buttons to the newly created control
CommandBarPopup commandBarPopup_CM = (CommandBarPopup)commandBarControl_CM;
CommandBarControl commandBarControl_SI = commandBarPopup_CM.CommandBar.Controls.Add(
MsoControlType.msoControlButton, 1, "", 1, true);
commandBarControl_SI.Visible = true;
commandBarControl_SI.Caption = "Calendar Sychronization";
//Add button event handlers
CommandBarButton button_showinfo = (CommandBarButton)commandBarControl_SI;
button_showinfo.Click += new _CommandBarButtonEvents_ClickEventHandler(button_showinfo_Click);
private void button_showinfo_Click(CommandBarButton Ctrl, ref Boolean CancelDefault)
{
System.Windows.Forms.Form form_CalMng = new Form_CalMng();
form_CalMng.Show();
}
|
|
|
|
|
Question 2 has been solved. The button object has to be declared at class level.
But help me with Question 1, please!
|
|
|
|
|
I begin to believe that it has something to do with the developing environment. I tried the Add-in on two computers WITHOUT VS2005 and got the same result, which is that the Add-in did not load. However, I tried it on another two computers WITH VS2005 on them and the Add-in loaded successfully.
Any hint?
|
|
|
|
|
Hi All,
A project I am working on requires me to interface DCOM components on a Windows NT machine with a server running 2003 with .NET 2 on it.
The problem is I can't seem to find any good advice on how this can be done. Specifically the client can not change and thus I require something like a wrapper so that the client can create a connection to the server via DCOM, but the server will be dealing with it via .NET remoting.
Can anyone point me in the right direction of how this can be done?
Thanks
Andy
|
|
|
|
|
Hello again,
I have looked in the docs and searched the net, but either it can't be done, or I'm not looking in the right place.
I would like have a property that is deserialised, but is not serialised. Why? Well, imagine an XML doc that allows
<person fullname="John Smith"/>
and
<person firstname="Jane" lastname="Doe"/>
However, when serialized we always want fullname, as in:
<person fullname="John Smith"/>
<person fullname="Jane Doe"/>
How do I deserialise firstname and lastname in the input file, but keep them from being serialised in the output?
Thanks again,
Clive Pottinger,
Hamilton ON
|
|
|
|
|
|
Hi
I'm affraid that's impossible but you can have a computed property ( which concats the first name and last name and returns the full name) and you can ignore it using XmlIgnore attribute.
I mean:
<br />
[XmlIgnore()]<br />
public string FullName<br />
{<br />
get<br />
{<br />
return this.FirstName + " " this.LastName;<br />
}<br />
}<br />
<br />
Regards
|
|
|
|
|
beatles1692 wrote: Hi
I'm affraid that's impossible but you can have a computed property ( which concats the first name and last name and returns the full name) and you can ignore it using XmlIgnore attribute.
Thanks. That's too bad. I'll have to see what I can do about changing the specs.
Clive Pottinger,
Hamilton ON
|
|
|
|
|
Bonus - I solved two in one day.
You can have an attribute that is deserialised but not serialised.
Give the item a property with a DefaultValue attribute and then have the get method always return the default value:
<br />
[XmlAttribute("firstname")]<br />
[System.ComponentModel.DefaultValue("----")]<br />
public string Firstname<br />
{<br />
get<br />
{<br />
return ( "----" );<br />
}<br />
set<br />
{ <br />
this.Firstname = value;<br />
}<br />
}<br />
Voila! Now, when deserialising, firstname is parsed, but when serialising, the firstname attribute is never written. Works like a charm.
Clive Pottinger,
Hamilton ON
|
|
|
|
|
Hello everyone,
My questions is in regards to finding information for an ancestor item while deserialising an XML document. The following is similar to the problem I am facing:
<teacher name="Johnson">
<class name="Hydrodynamics 101">
<student name="Billy"/>
</course>
</teacher>
I have classes for objects Teacher, Class and Student.
When a Teacher is deserialised, all the Class objects are created and passed to Teacher.AddClasses where each class is added to a private ArrayList Teacher.ClassList. Additionally, the Class.TeacherName is set. So far so good.
But during the creation of the Class objects, C# needs to create the Student objects. So the Student objects are deserialised BEFORE the Class objects are passed to Teacher.AddClasses. We are getting there...
When a Student object is created, I wish to add the student to the ArrayList Teacher.StudentList. That is a problem. Because the Class has not yet been added to the Teacher and had the Class.TeacherName value set, the Student object is unable to find out which Teacher it should be added to. We can't even search the Teacher objects looking for one that has that Class in Teacher.ClassList, because the Class has not been added there yet either.
Does anyone know a way around this? Is there a way, during deserialisation, to find out the Student["billy"] belongs to Teacher["Johnson"]?
Note: This is not exactly the situation I am facing: it is just a simplified example. So, though it may seem easier to rearrange the XML into a better order, that is not going to be an option for me. I need to deserialise object C inside B inside A and add C to a value in A while doing so.
Many thanks in advance.
Clive Pottinger,
Hamilton ON
|
|
|
|
|
Isn't it possible to set the teacher name in AddClasses . You could simply iterate through the student list in the class and set the teacher name.
|
|
|
|
|
That is the essence of the problem - I don't see a way to do it.
I'll try adding some code - I'm away from my development environment at the moment, and doing this from memory, so don't laugh too hard at my syntax errors... (I'm sensitive)
<br />
public class Teacher{<br />
private ArrayList ClassList = new ArrayList();<br />
private ArrayList StudentList = new ArrayList();<br />
[XMLAttribute("name");<br />
public string Name;<br />
[XMLElement("class")]<br />
public Class[] AddClasses {
get {return new Class[0];}
set {<br />
foreach( Class newClass in (Class[])value) {<br />
newClass.teacher = this.Name};
this.ClassList.Add(newClass);
}<br />
}<br />
}<br />
<br />
public class Class {<br />
[XMLAttribute("name")<br />
public string Name;<br />
<br />
[XMLIgnore]<br />
public string teacher;
[XMLElement("student")]<br />
public Student[] AddStudent {
get {return new Student[0];}
set {<br />
foreach( Student newStudent in (Student[]value) {<br />
newStudent.ClassesToGoTo = this.Name;
newStudent.MyInstructors = ?
}<br />
}<br />
}<br />
<br />
public class Student{<br />
[XMLAttribute("name");<br />
public string Name;<br />
private ArrayList ClassesToGoTo = new ArrayList();<br />
private ArrayList MyInstructors = new ArrayList();<br />
}<br />
<\code><br />
<br />
I know it's not complete, but hopefully it will illustrate my dilemma. <br />
<br />
<br />
-- modified at 13:39 Monday 6th November, 2006 <br />
<br />
<div class="ForumSig">Clive Pottinger,<br />
Hamilton ON</div>
|
|
|
|
|
The specific sequence of operations I see happening is this:
teacher nodes begin deserialising
-- Teacher object is created (oops I forgot the constructors in my example)
---- Teacher name is deserialised: set to "Johnson"
---- teacher/class nodes begin deserialising
------ Class object is created
------ class name is deserialised: set to "Hydrodynamics 101"
------ teacher/class/student nodes begin deserialising
-------- Student object is created
-------- student name is deserialised: set to "Billy"
------ all Student objects created
------ Student[] passed to Class.AddStudent
-------- Student["Billy"].ClassesToGoTo is set ("Hydrodynamics 101" is added)
******** Student["Billy"].Instructor should be set to ("Johnson")
******** Teacher["Johnson"].StudentList should have "Billy" added
-------- All students in Student[] processed
---- all Class objects created
---- Class[] passed to Teacher.AddClasses
+----- Class["Hydrodynamics 101"].teacher is set (oops missed defining that too)
+----- Teacher["Johnson"].ClassList is set ("Hydrodynamics 101" is added)
------ all classes in Class[] processed
-- all Teacher objects created
-- Teacher[] passed to unspecified routine
done
Again, notice that the ***** lines for Student processing require information that is not set until the +--- lines when the Class objects are processed. That is my problem.
Clive Pottinger,
Hamilton ON
|
|
|
|
|
How about setting the teacher value when "Class["Hydrodynamics 101"].teacher is set" occurs? You obviously have the list of students subscribed to the class, so you could just iterate over it and assign the teacher property?
|
|
|
|
|
Thanks for the help everyone.
I finally managed to solve the problem.
Since the deserialisation is "serial", it only works on one element at a time, working its way down through the child items. I decided to take advantage of that. I created another class (to continue my previous example, let's call it SchoolInfo) and gave it a static member which I use to track the current item being deserialised.
So SchoolInfo.CurrentTeacher is set to the Teacher object by the Teacher class as is being constructed. Now all Class objects and Student objects can look at SchoolInfo.CurrentTeacher as they are being constructed or as their attributes are being deserialised - it tells them which Teacher they going to be assigned to before they are assigned.
It may not be the prettiest, but it works.
Thanks again.
Clive Pottinger,
Hamilton ON
|
|
|
|