|
Yes.. On every client request create a new thread and run the task in its own thread until it returns to its tread pool.
Just like what IIS does for every requests.
|
|
|
|
|
can u be more specific im not getting any idea about it.
you mean to say when client send or recieve a msg run a new thread and reconnect to the server
|
|
|
|
|
i have tried running threads in this format. but this also works only if button is clicked and only for 4 times but
i wish 1 client to connect to the server when button is clicked and other client will connect and close for each minute.
the code is:-
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 4; i++)
{
Thread thread = new Thread(new ParameterizedThreadStart(round));
thread.Start();
thread.Join();
Thread.Sleep(100);
}
}
private void round(object val)
{
System.Net.IPAddress myIP;
System.Net.IPEndPoint myServer;
Socket socket;
string ip = (string)val;
try
{
myIP = System.Net.IPAddress.Parse(ip);
myServer = new System.Net.IPEndPoint(myIP, Int32.Parse("20000"));
socket=new Socket(AddressFamily.InterNetwork,SocketType.Stream ,ProtocolType.Tcp);
socket.Connect(myServer);
NetworkStream netStream=new NetworkStream(socket);
Byte[] byteMessage=new Byte[640];
string sendMessage="hello server";
byteMessage=System.Text.Encoding.Default.GetBytes( sendMessage.ToCharArray());
netStream.Write(byteMessage,0,byteMessage.Length);
netStream.Flush();
netStream.Close();
socket.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}
|
|
|
|
|
I'm writing strings at a pre-determined location to a bitmap.
Though, it seems that if the location isn't "snapped to the grid", blurring occurs.
Simple example:
public Bitmap WriteToBitmap(Bitmap bitmapToWriteTo, float X_Pos, float Y_Pos)
{
Graphics g = Graphics.FromImage(bitmapToWriteTo);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TextRenderingHint = TextRenderingHint.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.DrawString(this.text, this.font, new SolidBrush(Color.Black), X_Pos, Y_Pos, this.stringFormat);
return bitmapToWriteTo;
}
Nothing else is being done to the bitmap object or any of the other objects involved.
So you may consider the code above as being used as is.
The problem is, however, that using it like this, causes blurring in the text when drawn.
There is a solution to stop the blurring and that is by changing the TextRenderingHint:
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
Now, this causes the text being drawn to be "snapped to a grid".
However, this messes up my positioning, making it look chaotic.
My question is this, how can I get the result of TextRenderingHint.AntiAliasGridFit, without losing the positioning.
And, to what "grid" is the text being snapped to and am I able to manipulate it ?
|
|
|
|
|
Here's the solution as I can tell it at this point.
Dropping the following code solved the bluring for me:
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TextRenderingHint = TextRenderingHint.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
From what I understood by reading Microsoft supplied information and the experiences from other developers, it's the Glyph hinting that causes the problem.
I increased the DPI of the originating Bitmap and dropped the hinting.
Problem solved.
Some positioning adjustments are required, but nothing I can't fix.
Hope this will help others as well.
|
|
|
|
|
Sorry, its not to the problem itself, but I'm wondering.
You say "it's the Glyph hinting that causes the problem".
But on MSDN it says that TextRenderingHintAntiAlias does no hinting.
From MSDN: "TextRenderingHintAntiAlias:
Specifies that a character is drawn using its antialiased glyph bitmap and no hinting. Stem width differences may be noticeable because hinting is turned off. "
|
|
|
|
|
True, that's what they say.
I suggest you try it out and see if there's Glyph manipulation.
Set the TextRenderingHint property of your Graphics object:
g.TextRenderingHint = TextRenderingHint.AntiAlias;
See how it's displayed.
Then remove it and compare the two.
Even though it's already visibly apparent, I would like to urge you to print the two results and compare them.
In my humble opinion, the AntiAlias touches the Glyph.
But I could be mistaken.
If I am mistaken and somehow I seem to have missed what the default does as opposed to what AntiAlias does, then please inform me.
Don't forget to add an informative link, not just for myself, but for others coming across this problem.
Thanks in advance.
Edit:
I indeed stand corrected.
Here's a link explaining how it works:
http://msdn.microsoft.com/en-us/library/ms534404%28VS.85%29.aspx
By setting the TextRenderingHint to AntiAlias, you kill the default corrective Glyph hinting the Graphics object does by itself.
Quote:
"TextRenderingHintSystemDefault
Specifies that a character is drawn using the currently selected system font smoothing mode (also called a rendering hint)."
Quote:
"TextRenderingHintAntiAlias
Specifies that a character is drawn using its antialiased glyph bitmap and no hinting. Stem width differences may be noticeable because hinting is turned off."
Thank you Covean for this insight
modified on Thursday, October 22, 2009 9:07 AM
|
|
|
|
|
I can see the difference. And yes I also think it touches the Glyph, but there so no hinting.
The Problem with the "no hinting" is "Stem width differences may be noticeable because hinting is turned off."
Edit:
Oh I read your edit too late.
|
|
|
|
|
Not a problem, your thoughts in this have been insightful.
|
|
|
|
|
The plot thickens...
I was somewhat bored and still not satisfied with how the Graphics.DrawString() was working for me.
So I went on a Google hunt for some answers.
After looking around I came to a forum where a user had somewhat similar problems.
There he had linked a convo he had with a Microsoft MVP.
For more information please check this link:
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/362ab21b-1dc4-4140-a39a-a366beea9e40[^]
Quote:
"They couldn't fix the bugz in Graphics.DrawString() because way too much .NET 1.x code depended on its quirks. That's what Application.SetCompatibleTextRenderingDefault() is all about too. If you really want to use GDI+, you'll have to find the workarounds for the bugs yourself. Right now, using Graphics.DrawString() in a Paint event is a bug."
Quote:
"Graphics.DrawString() is too broken to be usable. It got replaced by TextRenderer.DrawText()."
To simplify things:
If you care for precision work, in particular with text rendering, then use the old GDI.
GDI+ is bugged and unusable for precision work.
If you don't care for precision work and you don't use text rendering (or very little of it or the quality isn't important), then use the new GDI+.
|
|
|
|
|
I faced the same problem, thanks
modified 1-Aug-19 21:02pm.
|
|
|
|
|
hi
How to pass any text value from form to Crystal Report ?
ex: i need to pass "hellow" from Form1 to my Crystal Report , how to do it ?
(working in C#)
thank's in advance
|
|
|
|
|
You create paramaters in crystal report. via that parameters u can pass
___________
rptCount = New ReportDocument
rptCount.Load(Server.MapPath("reportname.rpt"))
''Get the collection of parameters from the report
crParameterFieldDefinitions = rptCount.DataDefinition.ParameterFields
''Access the specified parameter from the collection
crParameter1 = crParameterFieldDefinitions.Item("Param1")
crParameter2 = crParameterFieldDefinitions.Item(“Param2")
''Get the current values from the parameter field. At this point
''there are zero values set.
crParameter1Values = crParameter1.CurrentValues
crParameter2Values = crParameter2.CurrentValues
''Set the current values for the parameter field
crDiscrete1Value = New ParameterDiscreteValue
crDiscrete1Value.Value = Request.Form(“param1value“)
crDiscrete2Value = New ParameterDiscreteValue
crDiscrete2Value.Value = Request.Form(“param2value“)
''Add the first current value for the parameter field
crParameter1Values.Add(crDiscrete1Value)
crParameter2Values.Add(crDiscrete2Value)
''All current parameter values must be applied for the parameter field.
crParameter1.ApplyCurrentValues(crParameter1Values)
crParameter2.ApplyCurrentValues(crParameter2Values)
|
|
|
|
|
Hello,
I have this structure :
Firstname; adresse; lastName
Aubenque; 20 wallstreet; Julien
Aubenque; 23 wallstreet; Julien
Bachelot; 22 londres street ; Maud
Aubenque; 25 wallstreet; Julien
Bachelot; 24 londres street ; Maud
Bachelot; 28 londres street ; Maud
Aubenque; 20 wallstreet; Julien
Bachelot; 22 londres street ; Maud
I would get the lines where the firstname and lastname was the same, help met to resolve this great problem, thank you verry mutch.
|
|
|
|
|
I didn't understand your problem. Can you explain it?
|
|
|
|
|
I am sorry, ok
I would get all line where the lastname and lastname was the same, i will get two elements for exemple in arraylist :
the first :
Aubenque; 20 wallstreet; Julien
Aubenque; 23 wallstreet; Julien
Aubenque; 25 wallstreet; Julien
Aubenque; 20 wallstreet; Julien
the second :
Bachelot; 22 londres street ;Maud
Bachelot; 24 londres street ; Maud
Bachelot; 28 londres street ; Maud
Bachelot; 22 londres street ; Maud
Thank you verry mutch
|
|
|
|
|
abbd wrote: I would get all line where the lastname and lastname was the same, i will get two elements for exemple in arraylist :
I am really sorry but i still didn't got your question.
What actually you need?
|
|
|
|
|
|
I need a book which describes about programming Microsoft windows.
I am using C#. I am reasonably sound in C (MCU work).
I can understand easily the syntax and structures in C#. But what confuses me is the many concepts like messages events. Also many terminologies like Guid, API functions etc.
I think I need a book to learn about the basics of windows programming.
C# books are not going much into that. They are teaching C# to a windows programmer.(At least I think So!)
Please suggest
With Regards
Roy Thomas
"..this file is known as source file probably because it is a source of frustration and anxiety!" - Chuck Sphar - In book 'C# 2005 for Dummies'.
|
|
|
|
|
|
I have Front End Microsoft C# 2005 Windows Application and Back End SQL Server 2005 Express Edition. I want to access SQL Server Express Data Base which is reside in one Computer, from 5 different location computers for adding and updating etc; records in Local Network Area.
Please guide me, how can I done the job.
|
|
|
|
|
|
hi.
How can I return IEnumerable<t> az a method parameter.
In fact I want to return a table records. but I must return as IEnumerable<t>;
How can I fill IEnumerable and return it?
|
|
|
|
|
Hi,
you have to write a class that will implement the IEnumerable interface. Within the implementation you can move through your records.
Have a look here:
http://msdn.microsoft.com/en-us/library/system.collections.ienumerable%28VS.80%29.aspx[^]
By the way, if you are using the System.Data.Table then the Rows-Property offers a GetEnumerator() method which will return an enumerator for the records within the table.
Regards
Sebastian
|
|
|
|
|
a world of thanks.
I 'll try to do it
|
|
|
|