|
Thanks,
My requirement is to only Insert the new records in a XML file( no modification, deletion)
Ashwani
|
|
|
|
|
You may loose inserted data too!
1. User A loads file.
2. User B loads file.
3. User A inserts data and saves it.
4. User B inserts data and saves it, and User A inserted data is lost.
|
|
|
|
|
Right !
Ok ! I was thinking what about accessing SQL database by Two Threads simultaneously !! I am planning to do something like,
[One thread is generating email address and email message and dump that record in SQL, another thread read email message from that SQL, send email and after that delete that record and scan any new record inserted]
A) Thread A inserts record in SQL
B) Thread B reads a record from SQL, may be the same one which was just inserted by Thread A.
C) Thread B do some work based on the information of that record.
D) Thread B Delete that record after finishing its work, and then look for new record again which was inserted by Thread A.
::: Now, Is there any chance of conflict ? I was worried about one thing, When Thread A is inserting record, does it lock the Database so that Thread B cannot read or delete any other record (not the exactly one which is being inserted) ? Or, When Thread B is reading or Deleting record, does it lock the database so that thread A cannot insert new record ?
Thanks and regards...
-- modified at 0:26 Thursday 23rd February, 2006
|
|
|
|
|
If you were back to the xml file thing, you could have a common write function used by the two threads, and a lock(this) at the start of the function so that the other thread cannot execute that method when one thread is inside it.
After every write into the file, you will have to save the file, so that when the next guy opens it, he will be appending to the already existing content of the xml file.
There has to be more to life than just this
|
|
|
|
|
Hello,
I understood about the XML file, but what about the SQL database file. Do i need to lock the database for similar operation ? Here I dont have multi user, but multi thread. I have two threads, one will insert record, another will read and delete record. at the same time, is there any chance of conflict and Hang ? Do I need to lock the database ?
|
|
|
|
|
If you are using independent connections as suggested already earlier, it all comes down to whether the database maintains integrity of transactions. Yes it does, that is why we pay so much money to use an Oracle or SQL Server database. If thread A is inserting a row into the database, the concerned tables will be locked and thread B will be made to wait before it can read or delete stuff.
So, yes, database is the most convinient method, albeit a tad slower.
There has to be more to life than just this
|
|
|
|
|
Something driving me insane that I cannot find in the options anywhere is how to turn of the auto-close functions so that when I type a quote like " I don't get another quote instantly. It drives me nuts. How can I disable that?
Thanks,
Rex
I only read CP for the articles.
Code-frog System Architects, Inc.
|
|
|
|
|
in development environment of .net, when design mode, Application.StartPath is the path of development environment, but run the application the path is program's path. I want to get the path what it is always the application the path is program's path. How to do it?
|
|
|
|
|
When you're in design mode, there is no program to have a path, the IDE is actually running your code.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
So....
I get UTC time from a C server in a 32-bit unsigned integer (aka long). Let's say for sake of discussion the UTC time is in the following variable:
uint utcTime;
And let's say I also have:
DateTime locTime;
And of course, there seems to be no combination of DateTime() methods that will address my simple need.
Any ideas?
Mike Luster
|
|
|
|
|
I'm not quite sure what you're asking. Are you trying to turn your uint into a DateTime?
Edit:
Boy, MSDN[^] is sure helpful:
Convert.ToDateTime Method (UInt32): Return Value
This conversion is not supported. No value is returned.
Jon Sagara
Look at him. He runs like a Welshman. Doesn't he run like a Welshman? Doesn't he? I think he runs like a Welshman.
Sagara.org | Blog | My Articles
-- modified at 21:02 Wednesday 22nd February, 2006
|
|
|
|
|
Yea, but the Uint32 that holds the time contains UTC formatted time from a C based program sent over ethernet. I pull it out of a packet, decode and now I need to be able to convert it to DateTime to be able to use it the C# app. Thanks
|
|
|
|
|
I believe the Uint32 value is the number of seconds since January 1, 1970 (most likely). Thus, to get the correct DateTime, you must initialize the your DateTime variable to January 1, 1970 and add the Uint32 seconds to it.
-- modified at 23:33 Wednesday 22nd February, 2006
|
|
|
|
|
Thanks for the tip George. Here's what I have encountered:
uint uval
DateTime dt = new DateTime( 1970, 1, 1 );<br />
dt.AddSeconds( uval );<br />
Console.WriteLine( "Date is {0}", dt.ToLocalTime( ) );<br />
Here is a real result to illustrate:
2/23/2006 11:49:15 AM: Raw POSIX Date-Time: 1140713262, Conversion: 12/31/1969 7:00:00 PM<br />
I printed out the 2K/POSIX value, followed by the conversion to local time. I was thinking the conversion should have yielded a date time along the lines of the message preamble 2/23/2006 11:49:15 AM give or take a few seconds in terms of synchronization w/ the server time. However it was off by just a few years!
I was curious to what was happening so I changed the dt.ToLocalTime() to dt.ToUniversalTime() and it yields 1/1/1970 5:00:00 AM. Since the DateTime is initialized to DateTime( 1970, 1, 1 ) this begs the question of just what is dt.AddSeconds( Convert.ToDouble( uval ) ) adding?
Interestingly if I print out dt without the ToLocalTime() conversion it yields 1/1/1970 12:00 AM. That means the seconds added should be 18000 to result in 1/1/1970 5:00:00 AM. This is why I am a little suspect of the 2K/POSIX value, it doesn’t make sense to me to added a 10 digit value and only yield a 5 hour delta since the 1970 epoch.
Now I have quadruple checked the packet decoding logic and I can tell you that all fields before and those after in a variable length packet are all correct and at the appropriate offset. Thus I have revisited the decoding and it appears to be OK in every respect less the date time situation.
At this juncture I am wondering if the 2K flavor of UTC requires any special consideration. Or is there something I am just plain missing? I am stumped.
Final FYI – according to the documentation from the Server vendor, the date-time is stored as followed:
TIME 4 Bytes A date/time, expressed as the number of seconds since Midnight January 1, 1970 Coordinated Universal Time (UTC).
So at least I know I am playing with the right deck,
Mike Luster
|
|
|
|
|
I have succeeded in getting my code to successfully do mouse clicks on a commercial program, running at a specific screen location, using this code:
SetForegroundWindow(targetWindowHandle);
input.type = INPUT_MOUSE;
input.mi.dx = 900;
input.mi.dy = 50;
input.mi.mouseData = 0;
input.mi.time = 0;
input.mi.dwFlags = 0;
input.mi.dwExtraInfo = 0;
SetCursorPos(input.mi.dx, input.mi.dy);
input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE+MOUSEEVENTF_LEFTDOWN);
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTUP);
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
The problem is, of course, if the window is moved, the clicks miss. I would love to be able to do the clicks relative to position 0,0 of the window pointed at by targetWindowHandle instead of relative to position 0,0 of the screen.
(I hope that statement makes sense to you guys.)
Any suggestions?
Thanks.
-- modified at 20:11 Wednesday 22nd February, 2006
|
|
|
|
|
for those interested ...
The solution was rather trivial after i found "GetWindowRect" in User32:
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll")]
public static extern int GetWindowRect(int hwnd, ref RECT rc);
// Get the target window's screen coordinates
RECT rect = new RECT();
int hwnd = GetWindowRect((int)targetWindowHandle, ref rect);
Persistence pays ...
---
-- modified at 15:34 Thursday 23rd February, 2006
|
|
|
|
|
I need to make a calcualtor (must be able to add, subtract, divide, and multiply). Two text boxes allow you to enter numbers which in turn does the math and prints to a seperate
|
|
|
|
|
Homework question?
jessica gelina wrote: and prints to a seperate
Missing end of sentence, the adjective should be followed by a noun.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
|
jessica gelina wrote: the only reference we got was that it is similar to the C++ method
Which is what?
You've got to be more specific about what your problem is in order for us to help. For example, I commented that in your first post the sentence ended midstream. So we can only guess or assume what you want.
You have two text boxes.
I'm assuming you have a bunch of buttons. +, -, /, *
I'm assuming you have a textbox or label for the result.
What part isn't working? What have you tried already?
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
i have two text boxes, and four buttons. Each text box allows for numbers, the buttons are teh math function. They then print the answer onclick to a seperate label.
I have tries adding the strings which simply put the two numbers in the box next to one another. I have tries sending the text.tostring function to the label.......
|
|
|
|
|
You need to convert it to an int before you can add them. Use this method:
<br />
int x = Convert.ToInt32(
int y = Convert.ToInt32(
<br />
Wacky waving inflateable arm flailing tube man!
- Family Guy
|
|
|
|
|
int x;
int y;
private void btnAdd_Click(object sender, System.EventArgs e)
{
int x = Convert.ToInt32.txtFirstNum;
int y = Convert.ToInt32.txtSecondNum;
x + y;
}
It doesn't recoginze the ToInt32! Is this supposed to be my answer label name?
|
|
|
|
|
jessica gelina wrote: int x = Convert.ToInt32.txtFirstNum;
int y = Convert.ToInt32.txtSecondNum;
Can't you at least copy/paste correctly????
Regards,
Nish
|
|
|
|
|