|
DocumentCompleted SHOULD fire when document is completed loaded. Try to find out why it is not working.
|
|
|
|
|
Thank you Shameel. That will be my primary focus today. However, one thing I noticed, is that some web pages hijack the focus (e.g. Google), 'holding' it in the search box. My feeling is that when this occurs, the DocumentCompleted will not fire.
WHEELS
|
|
|
|
|
I just created a small app to see myself what the problem is, and as you said, setting focus to the other control in DocumentCompleted event doesn't work. The reason I found is that DocumentCompleted is fired when the browser completes loading the html content of the page and google runs a javascript in its onload event to set focus to the search box. This happens after the DocumentCompleted event executes and therefore focus goes back to the control.
But ProgressChanged event works, and I found a workaround to do away with setting focus multiple times. Use this code:
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e) {
if (e.CurrentProgress == e.MaximumProgress) {
textBox1.Focus();
}
}
|
|
|
|
|
Works great. Thank you. WHEELS
|
|
|
|
|
how could i change this code to use the DirectorySearcher to get me all members in the group the reason i want to use the DirectorySearcher is because i can set the PageSize so i can get more than 1,000 users
currently all these groups have over 2,000 users
public static ArrayList testGetUsers()
{
ArrayList excludeGroups = new ArrayList();
ArrayList users = new ArrayList();
DirectoryEntry group;
excludeGroups.Add("CN=GMDPortal,OU=IT,OU=ADM,DC=corp,DC=ad,DC=ejhospital,DC=com");
excludeGroups.Add("CN=GService,OU=SysServices,DC=corp,DC=ad,DC=ejhospital,DC=com");
excludeGroups.Add("CN=GTrain,OU=Training,OU=ADM,DC=corp,DC=ad,DC=ejhospital,DC=com");
excludeGroups.Add("CN=GITLevSvcs,OU=LevSvcs,OU=IT,OU=ADM,DC=corp,DC=ad,DC=ejhospital,DC=com");
foreach (string DEgroup in excludeGroups)
{
group = new DirectoryEntry("LDAP://" + DEgroup);
foreach (object dn in group.Properties["member"])
{
users.Add(dn);
}
}
return users;
}
|
|
|
|
|
Hello,
i've wrote a server-application which should be able to hold a huge amount of TCPConnections (TCPClients).
I receive the messages asynchrone and every TCPClient is running in another Thread. Now, has somebody any experience in performance? How many Clients can i hold? Do i have any performance-issues if i hold them only (so no receiving and really working) and how many memory do they need? How many users are possible? 10...1000....1 000 000?
If somebody has any experience with that topic please share your experience.
Many thanks
softwarejaeger
|
|
|
|
|
Well, TCP/IP ports are int16 (so, 65536 values are possible), but some ports are already reserved, I think 0 is invalid, and so I must say the maximum possible connections are 60000.
I do not know how many memory they utilize, but for 64bit machines I think is very easy to use all of them.
And, if they are not sending data, they will only consume memory.
|
|
|
|
|
Server applications should only use one local port for communications, so the 65535 limitation on the port number doesn't affect the number of possible threads.
|
|
|
|
|
That's wrong.
Server applications use one port for Listening.
Each client connection then uses another port.
So, a server with 10 clients will use 11 ports:
1 port to listen for new clients,
and 1 port for each connected client.
|
|
|
|
|
Here's a simple server program demonstrating how the ports work. It'll accept 10 connections, hang onto each one for 30 seconds, then shut itself down. Telnet into port 2323 with a command prompt to connect. If you connect 3 clients, netstat will yield a similar output to this (client ports are random, so it's not exact):
Proto Local Address Foreign Address State
TCP workstation:1161 localhost:2323 ESTABLISHED
TCP workstation:1162 localhost:2323 ESTABLISHED
TCP workstation:1163 localhost:2323 ESTABLISHED
TCP workstation:2323 localhost:1161 ESTABLISHED
TCP workstation:2323 localhost:1162 ESTABLISHED
TCP workstation:2323 localhost:1163 ESTABLISHED
The client's ports are randomly assigned to a number over 1024, but note that the server will always use port 2323 for its communication. When a client connects, the server does not create a new connection on a secondary port for communications.
However, some protocols do work like you have described above, randomly using an additional port for a secondary connection (IE, FTP does for data transfers, which is why FTP servers behind firewalls are a pain in the butt ).
Server Code -
[STAThread]
public static void Main(string[] Args) {
TcpListener listener = null;
try {
listener = new TcpListener(IPAddress.Loopback, 2323);
listener.Start();
int connection_count = 0;
while(connection_count<10) {
if(listener.Pending()) {
TcpClient connection = listener.AcceptTcpClient();
ThreadPool.QueueUserWorkItem(new WaitCallback(Communicate), connection);
Console.WriteLine("Connection Accepted ({0})", connection_count++);
}
Thread.Sleep(1);
}
Console.WriteLine("Waiting 30 seconds for last connection to close.");
Thread.Sleep(30005);
Console.WriteLine("Shutting Down.");
} finally {
if(listener!=null) {
listener.Stop();
}
}
}
private static void Communicate(object Connection) {
if(Connection==null) return;
TcpClient client = (TcpClient)Connection;
StreamWriter writer = null;
try {
if(client.Connected) {
writer = new StreamWriter(client.GetStream());
writer.WriteLine("Connected. You will be disconnected in 30 seconds.");
writer.Flush();
Thread.Sleep(30000);
writer.WriteLine("Bye!");
writer.Flush();
}
} catch {
if(writer!=null) {
writer.WriteLine("Connection error.");
writer.Flush();
}
} finally {
Console.WriteLine("Closing Client.");
if(client.Connected) {
client.Close();
}
}
}
|
|
|
|
|
You are wrong.
Maybe the results are as you showed, but try showing the IP address of this:
TcpClient connection = listener.AcceptTcpClient();
This connection does not use the same port as the listener port. At least not in my computer.
|
|
|
|
|
connection.Client.LocalEndPoint shows the servers IP address and listening port (in my example, 127.0.0.1:2323). The connection.Client.RemoteEndPoint is the client address/port that is connecting to the server, which does have a randomly selected port above 1024.
|
|
|
|
|
Hi ,
I have data coming from a stored procedure in sql server. I was able to export the results to excel in asp.net page using a grid on the page i.e. if user wants to download it into excel file.
now I want same functionality, i.e exporting the results from query/stored procedure directly to excel in C# windows application. How can I do this.
I don't want to use a grid on my page.
|
|
|
|
|
Do not cross post.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
That was deleted as i posted in wrong forum.
|
|
|
|
|
I think I have already suggested one link to do this.
|
|
|
|
|
Thanx Abhishek Sur
modified on Friday, November 20, 2009 10:44 AM
|
|
|
|
|
Hi abhishek,
I also need to format my excel sheet as follows:
the data has different values in 5 columns for the same values in the first 10 columns.
I need to show the columns with same data only once and then just populate the columns whuich have different data for the same value in first 10 columns.
|
|
|
|
|
FEMDEV wrote: I need to show the columns with same data only once and then just populate the columns whuich have different data for the same value in first 10 columns.
I am totally stumped.... I am confused. Please let me clear this a bit.
|
|
|
|
|
Good Day All
i have the Following Function
private static void OMEGA_calcActvEqv()
{
SqlConnection conn1 = CommonFunctions.getSQLConnectionForThread(THREAD_DATA[0].ToString());
string SQL = "SELECT MAX(D.OFFS + 1) * MAX(R.OFFS + 1) FROM TBL_ROWS R, TBL_CLMN D; SELECT MAX(OFFS + 1) FROM TBL_ROWS;";
SqlCommand cmd = new SqlCommand(SQL, conn1);
SqlDataReader rdr = cmd.ExecuteReader();
int size = 0;
if (rdr.Read())
{
size = Convert.ToInt32(rdr[0]);
}
int maxPeriods = 0;
if (rdr.NextResult())
{
if (rdr.Read())
{
maxPeriods = Convert.ToInt32(rdr[0]);
}
}
rdr.Close();
SQL = "SELECT MEA.EQV [EQV], MEA.ACTV [ACTV] FROM MTM_EQV_ACTV MEA ORDER BY MEA.EQV, MEA.ACTV ";
if ((THREAD_DATA.Length > 3) && (THREAD_DATA[3] != null))
{
string EQV = CommonFunctions.ExecuteScalarInThread("SELECT MEA.EQV FROM MTM_EQV_ACTV MEA WHERE ACTV=" + THREAD_DATA[3], conn1).ToString();
SQL = "SELECT MEA.EQV [EQV], MEA.ACTV [ACTV] FROM MTM_EQV_ACTV MEA WHERE EQV='" + EQV + "' ORDER BY MEA.EQV, MEA.ACTV ";
}
cmd = new SqlCommand(SQL, conn1);
rdr = cmd.ExecuteReader();
string eqvSet = string.Empty;
List<int> actvs = new List<int>();
while (rdr.Read())
{
if (eqvSet != rdr["EQV"].ToString())
{
if (actvs.Count > 1)
{
OMEGA_intersectDomns(actvs, size, maxPeriods);
}
actvs.Clear();
eqvSet = rdr["EQV"].ToString();
if (!DBNull.Value.Equals(rdr["ACTV"]))
{
actvs.Add(Convert.ToInt32(rdr["ACTV"]));
}
}
else
{
if (!DBNull.Value.Equals(rdr["ACTV"]))
{
actvs.Add(Convert.ToInt32(rdr["ACTV"]));
}
}
}
rdr.Close();
if (actvs.Count > 1)
{
OMEGA_intersectDomns(actvs, size, maxPeriods);
actvs.Clear();
}
conn1.Close();
conn1.Dispose();
}
and the Definition of function ExecuteScalarInThread
is
public static object ExecuteScalarInThread(string sql, SqlConnection conn1)
{
SqlCommand sqlcommand = new SqlCommand(sql, conn1);
sqlcommand.CommandType = CommandType.Text;
object ret = new object();
if (conn1.State != ConnectionState.Open)
{
conn1.Open();
}
try
{
ret = sqlcommand.ExecuteScalar();
}
catch (Exception e)
{
ret = e.Message;
}
conn1.Close();
return ret;
}
i get an Error in the bolded line of the Function OMEGA_calcActvEqv() on this line
rdr = cmd.ExecuteReader();
that says
ExecuteReader requires an open and available Connection. The connection's current state is closed.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
You are closing the connection inside ExecuteScalarInThread method. That should be the problem.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Thank you very much. i had a LongDay.
that solved my Problem i can go home now
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Vuyiswa Maseko wrote: Thank you very much. i had a LongDay.
that solved my Problem i can go home now
Then you should mark that post as helful.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
How by Voting for it ? i have already done that. or did i miss something
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Vuyiswa Maseko wrote: or did i miss something
No !
Your are done !
Thanks !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|