|
See the System.Threading namespace as well. There's a lot of objects that can be signaled, like those deriving from WaitHandle . These classes and their members actually use the native APIs like WaitForSingleObject and encapsulate them in easy-to-use classes.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am trying to create a class iheriting from Hashtable. My aim is, it has to save (serialize) itself when a key/value pair is assigned to it. Also, it has to deserialize in the constructor.
I could make it work by haing the Hashtable as a member of my class, it couldn't do it when I tried to inherit my class from hashtable. Can any one help?
TOJO
|
|
|
|
|
It won't work when you deserialze (by default) since a new object is created from deserialization. What you probably could do is deserialize to a new object (a your Hashtable derivative) then enumerate through the DictionaryEntry objects (using the IDictionaryEnumerator from Hashtable.GetEnumerator ) and add them back into your current instance. When the deserialized Hashtable falls out of scope, it will eventually be garbage collected.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, thanks for reading my post.
I am trying to produce a custom control based on a textbox. This is to be distiguished from a regular text box by a small red triangle at the bottom right of the control.
I have managed to get the triangle to display correctly.
My problem is that when I enter text, it displays correctly but when the delete key is pressed, it does not remove the characters, it just moves the cursor back one space.
I have tried Invalidating the control every time a key is pressed (and in a few other events) but when this is done, the keypresses are registered (the cursor moves) but the text is not displayed.
I have even tried to make my event handler draw the text but that has given me a whole raft of other problems and I don't think that the background event should be drawing the foreground anyway.
The code for my OnPaintBackground event is as follows:
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
base.OnPaintBackground (pevent);<br />
<br />
Rectangle r = pevent.ClipRectangle;<br />
PointF[] pts = new PointF[3];<br />
<br />
int sideLength = 5;<br />
<br />
pts[0] = new PointF(r.Right, r.Bottom - sideLength);<br />
pts[1] = new PointF(r.Right - sideLength, r.Bottom);<br />
pts[2] = new PointF(r.Right, r.Bottom);<br />
<br />
pevent.Graphics.FillPolygon(Brushes.Red, pts);<br />
}<br />
Please help point me in the right direction (or if you prefer, you could always give me a finished example )
Thanks in advance
Stephen
|
|
|
|
|
DataSet ds = new DataSet();
ds.ReadXml(filePath);
dataGrid1.DataSource = ds;
dataGrid1.DataMember = "database";
dataGrid2.DataMember = "package";
Now dataGrid1 is on tabPage1 and dataGrid2 on tabPage2. He fills dataGrid1 correctly but how can i fill tabPage2? Because he doesn't do it like this.
thx in advance
|
|
|
|
|
bertcox wrote:
Now dataGrid1 is on tabPage1 and dataGrid2 on tabPage2. He fills dataGrid1 correctly but how can i fill tabPage2? Because he doesn't do it like this.
Uhhhh....You didn't supply near enough information to answer this. What is stopping you from filling dataGrid2?
RageInTheMachine9532
|
|
|
|
|
sorry! incredibly stupid mistake
i thought i already filled dataGrid2
thx
|
|
|
|
|
Does anyone know how to move
a row (in DataTable or DataSet or DataGrid)
I mean: for example
present fourth row as a fifth
and fifth as a fourth
doesn't work!?
DataSet ds = (DataSet)dataGrid1.DataSource;
ds.Tables[0].Rows.InsertAt(dr,i);
|
|
|
|
|
Do some free class libraries for long numbers computition exist? And where I can find one?
Jast a student!
|
|
|
|
|
Lego Bragis wrote:
Do some free class libraries for long numbers computition exist
Your question is a bit too vague to answer. What are you looking for in the way of computations? And what do you mean by 'long numbers'?
RageInTheMachine9532
|
|
|
|
|
First of all, I am sorry for my English.
I mean that i need library for working with sach big numbers, that they can be represented with no simple types (int, long, etc.).
Jast a student!
|
|
|
|
|
Have you looked into the Double type?
From the VS Docs:
The Double value type represents a double-precision 64-bit number with values ranging from negative 1.79769313486232 e 308 to positive 1.79769313486232 e 308, as well as positive or negative zero, PositiveInfinity, NegativeInfinity, and Not-a-Number (NaN).<br />
<br />
Double complies with the IEC 60559:1989 (IEEE 754) standard for binary floating-point arithmetic.
There is also a LargeNumber class here on CP at http://www.thecodeproject.com/cpp/largenumber.asp[^].
You might also want to Google for 'Large Number Class'. You'll find a project on SourceForge.net.
RageInTheMachine9532
|
|
|
|
|
'Large Number Class' is almost what I need. But actually I need .Net class. I think I found it here : http://www.codeproject.com/csharp/BigInteger.asp?print=true
Thank you. Google - RULEZZZZZ!
Jast a student!
|
|
|
|
|
Math class should be sufficient shouldnt it!
your can use 64bit ints aswell!
|
|
|
|
|
Hello. How can I use Internet Explorer DOM from C# program?
Jast a student!
|
|
|
|
|
You can add the IE COM component to your project. Go to the Toolbox and right-click in it. Select 'Add/Remove items...', then click on the 'COM' tab. Find the 'Microsoft Web Browser' (shdocvw.dll) and make sure the checkbox next to it is selected. Click OK to add the Browser component to the Toolbox. Then go back to the Tookbox and drag the component onto your form.
RageInTheMachine9532
|
|
|
|
|
What Dave said will only add the AxWebBrowser control, which is defined in the AxInterop.SHDocVw.dll assembly. Additionally, a Interop.SHDocVw.dll assembly is created that contains the delegates and interfaces needed to interface with it. If you want to actually traverse and interface with the DOM, you need to add a reference to the Microsoft.mshtml.dll assembly (probably in your GAC, but should be on your system when you install VS.NET et. al.).
Then, to get an instance of the IHTMLDocument2 interface, cast axWebBrowser1.Document to IHTMLDocument2 . In .NET, casting COM-defined interfaces is the same as QI'ing (QueryInterface ) for them like you would in COM. If you get a null reference, it means the interface is not supported.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ahh. Thanks Heath!
RageInTheMachine9532
|
|
|
|
|
Hi there!
I wrote an application which calls several methods of a WebService. But how can i set the URL where the WebService is located AFTER compiling my application?
Thanks for reading
|
|
|
|
|
Hi flaffy,
To Call methods which are exists in the Web Service into your application.....go to your application and check the references and right click on it and select the Add Web refernces it will popup a form for the web service URL there u have to provide your web service url to get all the methods ...then click on Add button it will automatically add to ur web references.
Thanks
Ramakrishna.J
SoftProSys.ltd.
|
|
|
|
|
You can change the path to a web service using Url property inheritted from WebClientProtocol (in the web service proxy class that your client uses). To externalize this settings, you can add it to your .config's <appSettings> section and read it in with ConfigurationSettings.AppSettings["yourKeyName"] . You can also configure your proxy in VS.NET to do the same thing using the designer, but I don't remember off the top of my head how. Just explore.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks Exactly what i had looked for
|
|
|
|
|
I tried to insert data into SQL server database using the following code. All data that I received from all my connections (10 socket). It runs for sometime and I was able to insert some data then suddenly in the middle of the process I encountered
System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first.
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean executing)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at ossrop.Class1.SaveToSQLDB(String strFile, String strOpt) in d:\ossrop\class1.cs:line 560
I declare my DBConnect as modular and with CONNECTION POOLING.
//DBConnect = new SqlConnection("Pooling=true;server=OSSSQL01;database=nfmse;uid=alarmadmin;pwd=alarmadm1n;Min Pool Size=3;Max Pool Size=100;");
DBConnect.Open();
Processdata()
{
iRx = theSockId.thisSocket.EndReceive (asyn);
char[] chars = new char[iRx]; // + 1];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
StringBuilder szData = new StringBuilder();
szData.Append(chars);
SaveTOSQL();
}
void SaveTOSQL()
{
string strInsert = "insert into rop values ('" + strjv.Trim() + "','" + strdate.Trim() + "','" + strclass.Trim() + "','" + strFile + "','" + strFile + "')" ;
DBCommand = new SqlCommand(strInsert,DBConnect);
DBCommand.ExecuteNonQuery();
}
PS : I don't close the connection nor the command becuase this is a 24 hour process.
Thanks in advance.
/dabsukol
|
|
|
|
|
One of two possibilities that I can think of.
(1) You read data with a DataReader and didn't close it when you were done reading.
(2) You are still reading data with the DataReader when you call the code to insert data on the same connection as the DataReader .
The solution for (1) is to remember to Close() DataReader s when you're done with them.
The solution for (2) is to open a new connection because you cannot run two or more commands on the same connection at the same time. (The Data Reader is still running the command because it doesn't get the data from the database until it neads it) - Since you're using Connection pooling this isn't much of an overhead.
Actually since you're using Connection pooling why not close the connection after each operation the any subsequent operations will just pull the connection back out of the pool.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Hi,
Your're correct I 'm seleceting records from the first table using ofcourse the Connection. then, while selecting ip/ports from my first table i'm also at the same time inserting data into the 2nd table with the same connection. That's why I got this error message.
Solution: all data selected from the 1st table is temporarily inserted into an array variable and from it I try to run connect and insert retrieved data into SQL using a different connection. At the same time I use a Connection Polling.
SqlConnection sqlconn = new SqlConneciotn(connstring)
open connection
Select from table1
insert into array variable
close connection
SqlConnection sqlconn = new SqlConneciotn(connstring)
open connection
insert into SQL
close connection
It work so far. Thank you very much and God Bless you.
/dabuskol
Ps : My program is running for 1 1/2 hour now with no problem registering to the log file and console.
|
|
|
|