|
|
Hi,
I trust that the following link Windows Services[^] will provide an answer.
Regards,
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
|
Which line is throwing the extension? If it is line 211 then either
1. dataSet is null or
2. there is no table called ProductGroup
|
|
|
|
|
Hi again .. the problem it was with the table called ProductGroup <-- i used the index 0 and it worked
thought that the null exception was because of the Row .. and not the Table.
sorry for bugging you.
i can say thank you . for helping me .. and thank you very much :$
lol
|
|
|
|
|
DO NOT delete your original message after someone has answered the question.
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
I second that. Very irritating when people do that. I was curious to see what the problem was, and wanted to add my two cents worth. Now, it isn't there and I can spend my two cents worth here
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi,
I am using a regular expression (100|\s*(\d{0,2})((\.|\,)(\d{2,4}))?\s*\%?\s*) to display a percentage correctly on a property.
The RegEx works 100% for displaying the correct value visually. But after the user has entered the value on the property i.e. 95.25% I would like to retrieve a value of 0.9525 without writing code on the property.
Would I be able to do this by setting either the DisplayFormat or EditMask attribute to something else?
Thanks
|
|
|
|
|
|
Nee jou wetter dit werk nie, dankie vir die post Jannes
|
|
|
|
|
|
Dit is meer as dit. Die property het drie attributes nl EditMask, EditMaskType en DisplayFormat. Jy moet EditMask en EditMaskType saam gebruik m.a.w jy se vir EditMask watter tiepe Mask jy gebruik nl enum { Simple, RegEx }. MSDN se ek behoord {0:P4} (P/p = Percentage) RegEx te gebruik maar dit werk ook nie reg nie.
|
|
|
|
|
|
|
Can't you just strip the % sign then divide by 100?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
That would require me to write code on that layer, something i want to avoid. I want to keep all formatting related issues within the same layer
|
|
|
|
|
You're going to have to write code somewhere or you can't change the behavior.
The easiest way when you have two properties that are the same essentially (apart from how they are displayed or their type etc) is to make one the master and the other the slave.
For example - Text and Value properties, Value being the master.
private int m_Value;
pubilc string Text
{
get
{
int result = Value;
return string.Format("your format", result);
}
set
{
int result;
int.TryParse(value, out result);
Value = result;
}
}
public int Value
{
get { return m_Value; }
set
{
m_Value = value;
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Assume 3 or 5 textbox which will be filled by user at runtime (v dont know how many he will fill)
and these values should assigned to radio button text which will be created dynamically.
how to do this?
Krish
modified on Thursday, November 6, 2008 4:55 AM
|
|
|
|
|
Ok, ive considered it - now what? Did you have a question?
Edit: You asked ther same question 4 hours ago and said the solution you were given was working
|
|
|
|
|
Look u r totally in confusion the question which i posted first is different from the thing i posted now....
Sorry to say this friend
The fact is u cant understand the question...
Dont make funny on others think first u r fit to do that...
|
|
|
|
|
Bala K wrote: The fact is u cant understand the question...
Where is the question?
Bala K wrote: Assume 3 or 5 textbox which will be filled by user at runtime (v dont know how many he will fill)
and these values should assigned to radio button text which will be created dynamically.
Hmm... yes i assumed it. Goody goody?
-------------------------------------------
It's code that drives you - Shyam
|
|
|
|
|
|
Iterate through the controls, test each control is a TextBox and build a string from those that are.
Rough example:
string BuildRadioText()
{
StringBuilder textBuilder = new StringBuilder();
foreach (Control control in Controls)
{
if (control is TextBox)
if (Text.Length > 0)
{
if (textBuilder.Length > 0)
textBuilder.Append(", ");
textBuilder.Append(control.Text);
}
}
return textBuilder.ToString();
}
RadioButton dynamicRadio = new RadioButton();
dynamicRadio.Text = BuildRadioText();
Controls.Add(dynamicRadio);
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
modified on Thursday, November 6, 2008 10:37 AM
|
|
|
|
|
I'm developing an application in which multiple clients exchange data on a TCP link with a server using a custom protocol. I've chosen the asynchronous approach to implement the server.
Below I've attached an excerpt of my code, showing the points discussed in my questions. I have several doubts about correct asynchronous callback usage, and I could not find anything in the docs:
1) Suppose you have several clients connected. Do all the callbacks (OnClientConnect , OnClientRead ...) "live" in the same thread? That is, while I'm inside OnClientRead to serve one of the clients, can my code be interrupted by an OnClientRead from another client?
I performed a simple investigation, and it seems that OnClientRead for different clients are called from the same thread. So, it seems that OnClientRead execution never gets interrupted. Am I right? Is this always true? If so, I think I can safely remove all the lock statements for clientList access.
2) Is it correct to always launch a new AsyncCallback every time? e.g. new AsyncCallback(OnClientRead) inside OnClientRead . Does this waste resources? Should I keep a different AsyncCallback for each client and reuse it?
Regards,
Andrea
class ClientState
{
}
class NetworkServer
{
private List<clientstate> clientList;
private object lockObject = new object();
public void Start(int backlog)
{
clientList = new List<clientstate>();
serverSocket.Listen(backlog);
serverSocket.BeginAccept(new AsyncCallback(OnClientConnect), null);
}
private void OnClientConnect(IAsyncResult state)
{
Socket clientSocket = serverSocket.EndAccept(state);
ClientState clientState = new ClientState();
...
lock(lockObject)
{
clientList.Add(clientState);
}
clientSocket.BeginReceive(clientState.Buffer,
0,
clientState.Buffer.Length,
SocketFlags.None,
new AsyncCallback(OnClientRead),
clientState);
serverSocket.BeginAccept(new AsyncCallback(OnClientConnect), null);
}
private void OnClientRead(IAsyncResult state)
{
SocketError socketError;
int numBytes = clientSocket.EndReceive(state, out socketError);
if ((numBytes == 0) || (socketError != SocketError.Success))
{
clientSocket.Shutdown(SocketShutdown.Both);
clientSocket.Close();
lock(lockObject)
{
clientList.Remove(clientState);
}
}
else
{
...
clientSocket.BeginReceive(clientState.Buffer,
0,
clientState.Buffer.Length,
SocketFlags.None,
new AsyncCallback(OnClientRead),
clientState);
}
}
}</clientstate></clientstate>
|
|
|
|
|
Hi again Andrea. That's looking good.
Metal76 wrote: 1) Suppose you have several clients connected. Do all the callbacks (OnClientConnect, OnClientRead...) "live" in the same thread? That is, while I'm inside OnClientRead to serve one of the clients, can my code be interrupted by an OnClientRead from another client?
I performed a simple investigation, and it seems that OnClientRead for different clients are called from the same thread. So, it seems that OnClientRead execution never gets interrupted. Am I right? Is this always true? If so, I think I can safely remove all the lock statements for clientList access.
The callbacks happen on a thread pool thread. This means that each callback owns it's thread while it is executing and will not be 'interrupted'. However, the thread pool has many threads! Each callback is handled separately, so it may or may not execute on the same thread pool thread each time.
If multiple clients are active at the same time, you may have many threads from the pool, each executing OnClientConnect or OnClientRead for a particular client. This means that you do have to protect your shared state ( clientList ) by using a lock, just as you have done.
Metal76 wrote: 2) Is it correct to always launch a new AsyncCallback every time? e.g. new AsyncCallback(OnClientRead) inside OnClientRead. Does this waste resources? Should I keep a different AsyncCallback for each client and reuse it?
Yes, you have to start a new BeginXXX call each time to continue accepting clients and receiving data. The AsyncCallback is just a delegate, so doesn't waste much. You can declare an instance in your class, instantiate it in a constructor, and reuse it each time. It doesn't really matter, though.
Just as a matter of style, I would put the calls to BeginAccept and BeginReceive in a private method each, just so you don't have two copies of each call.
Nick
----------------------------------
Be excellent to each other
|
|
|
|