|
Thanks so much for your help! I've got it!
I will try to correct my code more properly according to your guide.
Thank you so much for another time!
Have a nice day!
|
|
|
|
|
Hi,
I have been thinking... Let's assume that I have a server application and lots of clients all over the world connect to my server by using TCP protocol. When a client sends me a connection request, my server application creates a thread for the client and do the rest of the communication in that thread. As far as I know, after some number of threads, operating system starts to get mad and refuses to create more threads. This causes my application to deny to service.
How is this problem solved? Am I missing a point?
Thanks in advance.
|
|
|
|
|
Use asynchronous methods instead of synchronous ones (i.e. use BeginReceive instead of Receive ). This allows you to not have to explicitly create/destroy a thread for each connected client; instead, the async callbacks are executed on Thread Pool threads which are managed by the runtime.
The code required to implement an async client/server can be more complex than the alternative but it solves this specific problem. Once you spend some time and really get familiar with the async way of doing things the complexity will cease to be a factor and you won't know how you lived without it .
|
|
|
|
|
As suggested, asynchronous methods can solve this problem. But you should be very careful when using it. It can make your code unnecessarily complicated. IMO, you should choose it only when it is necessary.
I'd suggest to use a thread pool rather than creating new thread each time. It should scale well in most scenarios. For more scalability than that, asynchronous method is the way to go.
Best wishes,
Navaneeth
|
|
|
|
|
Hi
I have the code to make the backup of the MySql database like this..
try
{
DateTime backupTime = DateTime.Now;
int year = backupTime.Year;
int month = backupTime.Month;
int day = backupTime.Day;
int hour = backupTime.Hour;
int minute = backupTime.Minute;
int second = backupTime.Second;
int ms = backupTime.Millisecond;
String tmestr = backupTime.ToString();
tmestr = "C:\\" + year + "-" + month + "-" + day + "-" + hour + "-" + minute + ".sql";
StreamWriter file = new StreamWriter(tmestr);
ProcessStartInfo proc = new ProcessStartInfo();
string cmd = string.Format(@"-u{0} -p{1} -h{2} {3} > {4};", "root", "password", "localhost", "dbfile", "backup.sql");
proc.FileName = "mysqldump";
proc.RedirectStandardInput = false;
proc.RedirectStandardOutput = true;
proc.Arguments = cmd;//"-u root -p smartdb > testdb.sql";
proc.UseShellExecute = false;
Process p = Process.Start(proc);
string res;
res = p.StandardOutput.ReadToEnd();
file.WriteLine(res);
p.WaitForExit();
file.Close();
}
catch (IOException ex)
{
MessageBox.Show("Disk full or other IO error , unable to backup!");
}
}
while executing the program it is showing an error like
"The system cannot find the file specified" with caption "Win32Exception was unhandled "...
can anyone help in this.....
|
|
|
|
|
you can change the mysqldump file path like
C:\wamp\bin\mysql\mysql5.1.36\bin\mysqldump
for the using wamp server;
|
|
|
|
|
what is the use in Xampp server
|
|
|
|
|
hello all
i want to know how to get DateTime array through DataReader and set it as bolded Dates on MonthCalender
i have the following code ..
SqlCommand GetDates = new SqlCommand();
GetDates.Connection = new SqlConnection(ConS);
GetDates.CommandType = CommandType.Text;
GetDates.CommandText = "select Reserve_Date from reservations where Done = 0";
GetDates.Connection.Open();
SqlDataReader rd = GetDates.ExecuteReader();
while (rd.Read())
{
DateTime ReservDays = (DateTime)rd["Reserve_Date"];
monthCalendar1.AnnuallyBoldedDates = new DateTime[] { ReservDays };
}
rd.Close();
GetDates.Connection.Close();
the reader works fine but the result is the last row only
i want to get all rows and set it as AnnuallyBoldedDates on monthCalender
thanks in Advance
|
|
|
|
|
Mr.Kode wrote: the reader works fine but the result is the last row only
Because you are overwriting the variable in each iteration. You need to get everything into an array and finally set to monthCalendar1.AnnuallyBoldedDates . Since you don't know the number of items, it is easy to use a List .
var list = new List<DateTime>();
while (rd.Read())
{
DateTime ReservDays = (DateTime)rd["Reserve_Date"];
list.Add(ReservDays);
}
monthCalendar1.AnnuallyBoldedDates = list.ToArray(); Your code can be improved further by calling Dispose() on SqlConnection, command and reader.
Best wishes,
Navaneeth
|
|
|
|
|
thanks Navaneeth
this really helps
but how Dispose method improve performance?
|
|
|
|
|
Performance is not the reason to call Dispose . It avoids resource leaks. When you dispose your connection properly, ADO.NET's connection pooling can work efficiently. Here is a decent article on the subject : Implementing IDisposable and the Dispose Pattern Properly[^]
Best wishes,
Navaneeth
|
|
|
|
|
Your statement "monthCalendar1.AnnuallyBoldedDates = new DateTime[] { ReservDays };" recreates the array on each iteration.
And also, the statement "DateTime ReservDays = (DateTime)rd["Reserve_Date"];" is needless.
I also recommend using a try/finally, with the rd.Close() in the finally. And a using statement for the connection.
|
|
|
|
|
how do i call a c# funcation in html code, on link's onclick?
i have already called a function onclick, i need to call another function.
kindly help me out....
Thanks
Saurabh
|
|
|
|
|
Assuming I understand your question you just need to name the second function as something else, e.g. OnClickTwo() .
btw please do not use bold font for your question.
|
|
|
|
|
Firstly, try such questions in the ASP.NET forum - you are more likely to get usefull replies.
I assume you are trying to call a C# function in the code behind (server code)? In which case just make the link runat="server" and the onclick event should pick up C# code.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
As someone else said, we have an ASP.NET forum. I hate to say this, because it's a library overused by all sorts of clueless people, but AJAX may be what you're looking for. The alternative is simply to have a server control call a code behind method and do a postback.,
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
thanks everyone..........for ur support.
|
|
|
|
|
saurabh8april wrote: funcation
Excuse me, but BWAAAA-HA-HA-HA-HA! My sides hurt! You guys slay me!
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
gud afternoon
i have a problem
i have a taextbox and i want to enter in it only 2 digits or 11 digits
example
12 valid
123 invalid
12345678912 valid
123456789123 invalid
plz. rply its urgrnt
|
|
|
|
|
You don't need Regex(Regular Expression)
Use can use Leave event :
private void textBox1_Leave(object sender, EventArgs e)
{
if (textBox1.Text.Length != 2 && textBox1.Text.Length != 11)
throw new Exception("invalid");
}
modified on Saturday, November 7, 2009 10:03 AM
|
|
|
|
|
I think you want an && , not an || .
|
|
|
|
|
Yeah, You're right. Thanks
|
|
|
|
|
hai......
help me plz...i done this prob ..but that count nums displaying in same in file path....i want to dispaly in saparate path ....
i took paths lik..|sno|filename|count|...........n i take multiple files which is displaying in sno....but char count was nt dispalying in count path.......its displaying in filename path...
plz help me how can i get that count in next path....?
thanquuu.
|
|
|
|
|
What on earth does this mean?
Try to clarify your problem and spell words in full, please do not use 'txtspk' it makes you question look like gibberish.
|
|
|
|
|
Hiii all..........
I need helping if you don't mined that >>> i think you don't mined ............
How i can use "winpcap" or "sharpcap" to capture and redirect all incoming packets using C#.net windows application ???????????
|
|
|
|