|
If you were pointing at this from the beginning you wouldn't have the dll added to your project.
Just right click the toolbar and then choose Add/Remove items Link and click on it ,and then browse to your dll and every control contained in it will be added to the toolbox and then by only dragging it to your form the reference to this dll will be added automatically .
|
|
|
|
|
Yet again I am stuck. I've followed many code examples, most of which are wholly different and do not explain the small details I am lacking in my implementation. Basically what has happened is that, using the Async message sending I have implemented, the messages run together and mix data, which is obviously no good. I assumed that the Async BeginSend took care of this, but I guess I was wrong, either that or I did it wrong. The code below is my basic implementation:
<br />
public void SendMessage(String msg) <br />
{<br />
try<br />
{<br />
if(m_sndCallBack == null) <br />
{<br />
m_sndCallBack = new AsyncCallback(OnDataSent);<br />
}<br />
SocketPacket packet = new SocketPacket();<br />
packet.thisSocket = m_clientSocket;<br />
<br />
packet.dataBuffer = Encoding.UTF8.GetBytes(msg);<br />
<br />
m_clientSocket.BeginSend(packet.dataBuffer,<br />
0, packet.dataBuffer.Length,<br />
SocketFlags.None, <br />
m_sndCallBack, <br />
packet);<br />
}<br />
catch(SocketException se)<br />
{<br />
Debug.WriteLine(se.Message);<br />
} <br />
}<br />
public void OnDataSent(IAsyncResult asyn)<br />
{<br />
SocketPacket theSockId = (SocketPacket)asyn.AsyncState;<br />
try<br />
{<br />
int iRx = theSockId.thisSocket.EndSend (asyn);<br />
theSockId.thisSocket = null;<br />
}<br />
catch (ObjectDisposedException )<br />
{<br />
Debug.WriteLine("Web.OnDataReceived: Socket has been closed");<br />
}<br />
catch(SocketException se)<br />
{<br />
Debug.WriteLine("Web.OnDataReceived: "+se.Message);<br />
}<br />
}<br />
Now my typical calling, which may be the problem? would be:
ClientServer.SendMessage("CONNECT:username:password");
...
ClientServer.SendMessage("REQUEST:STATUS");
ClientServer.SendMessage("REQUEST:LIST");
and the server receives:
CONNECT:username:passwordREQUEST:STATUS...
Am I supposed to be waiting on the data to be sent? And if so, should I not even implement the sending using Async code? Any help would be greatly appreciated.
|
|
|
|
|
If your protocol demands that messages must be sent in a particular order, then you shouldn't use BeginSend. Each BeginSend will use a threadpool thread to run, so there is no guarantee as to the order in which the messages will actually be sent.
Waiting till the callback completes before sending the next message will solve your problem.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Where would the best place to implement the wait be?
If only I could find GOOD async code to model my implementation hah...
I am contemplating just writing synchronously and reading asynchronously because it doesnt really matter what order the messsages are received just that they are a single message.
Thanks
|
|
|
|
|
Is it OK if the server receives message like
REQUEST:STATUSCONNECT:username:password... ??
That's what I meant by the ordering problem, your messages themselves could get mixed up.
I'd typically implement this by creating my own thread and running a queue system there. All messages to be sent are posted to the queue and the queue synchronously processes them.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks, works beautifully, I figured the problem was the Async sending but I wasn't sure.
|
|
|
|
|
who's use powerbuilder tool or have ebook ! please help me.
thank you very much.
|
|
|
|
|
Hi folks,
I want to write a piece of code to check if a domain user is member of a local group in my machine. I've read some articles but I don't think I can use LDAP here.
Could you guys give me a hint?
Thanks a bunch.
|
|
|
|
|
Hi,
I'm trying to write an Out of proc DCOM server in C#. I have the Server written, its now a COM object so thats done.
Where i'm stuck is this. As far as I kmow, DCOM works by having a stub object on the machine that the server is running on, and then a proxy on each of the client machines that communicates with the stub object.
How are the stub and proxy objects created? I'm told that in C++, they are created automatically but I am developing this in C# so I need to know if it works the same. The client is written in C++ and the DCOM server is written in C#.
Any help or comments will be appreciated
Thanks
Millzy
|
|
|
|
|
hi to all of you, i'm developing a voice over IP application
i need it for a web page also
i studied the directX to include directX sound i suppose
i need it but that didn't work on asp.net
all i found over the internet is applications made in c++
i needed for .net languages so i have 2 questions :
1- is directX Applicable in web pages
2- the way to develop a library of my own what do need to code in this library so i can used it as a component
i really do need help about this cause i found such components on the internet but are not for free
and if i buy it i don't suppose they send me the source code
so for all the experienced out there DO YOU HAVE THE SOLUTION i need HELP
send me mail to charbel_zibara@hotmail.com
|
|
|
|
|
ASP.NET is a server-side only technology that generated HTML pages for a client. You cannot use DirectX in an ASP.NET app. Since a web page cannot access hardware on the client computer, you'll have to develop a control that the client will have to install to do VoIP. No, I don't have ANY code to do this, nor do I have any source of information on it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How could I change the format of the DateTime ?
The local Date is in the "dd-mm-yyyy" but SqlDbType is in "mm-dd-yyyy" format .
Thanks in advance.
|
|
|
|
|
We use
time.ToString("G", DateTimeFormatInfo.InvariantInfo);
and you should also consider using
time.ToUniversalTime();
before storing times in the database, to avoid problems with daylight saving.
|
|
|
|
|
If you want to store a date in SQL server, use parametized queeries, and that'll solve the problem, in any format SQL Server uses.
DateTime myDateTime = .....
string sql = "UPDATE People SET BirthDate = @Date WHERE ID_person = 1";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@Date", myDateTime);
cmd.ExecuteNonQuery(); That will save the correct date, no matter what format is the local computer, and/or SQL Server's computer using.
Alternatively, there's a way to change the date format for SQL Server, but I don't remember the exact syntax. Using parametized queries, I don't need it.
Also, parametized queries help avoid SQL injection attacks, so I'll recommend them for every circumstance.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
hi,
easy way is give dateTime as string Format..
ex:-
DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt")
Now No need to worry when local time and sqldbtype is different.
regards,
pubudu.
|
|
|
|
|
Hello,
In Windows Forms, I have a datagrid that is sortable by clicking on the column headers.
Say 2nd record is already selected and I sort the datagrid.
Now the previously selected row is unselected. At this point how do I get the index to this previously selected row to have it selected again.
Thank you.
|
|
|
|
|
In the sort event ,Just before the sorting itself ,take that value and put it in any other field and then retrieve it when you want.
|
|
|
|
|
Sorry but I have no clue what you are referring to!
What sort event? There is no sort event. There is only an event called ListChanged in the datagrid's dataview that fires on (and not before) sorting the datagrid. Another thing is, the dataset still has the same indexing order on the datagrid, meaning, a particular row's index before or after sorting remains intact eventhough after sorting it's position on the datagrid has changed.
|
|
|
|
|
Hi,
I have a possible solution for you - it has a couple of drawbacks, but might help.
This example assumes that you have a DataGrid called dataGrid1, who's DataSource is a DataTable called dt.
It also assumes that you've declared an ArrayList called al.
First of all, set the "AllowSorting" property of dataGrid1 to "false" - you have to sort it manually.
Then add the following event handler code (don't forget to wire it up to dataGrid1's DataGrid1MouseDown event in the Properties Grid).
void DataGrid1MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt);
if(e.Button == MouseButtons.Left)
{
if (hti.Type == DataGrid.HitTestType.ColumnHeader)
{
DataColumn dc;
dc = dt.Columns[hti.Column];
al = new ArrayList();
for(int i = 0; i < dt.Rows.Count; i++)
{
if (dataGrid1.IsSelected(i))
{
listBox1.Items.Add(dt.Rows[i][0].ToString());
al.Add(dt.Rows[i][0].ToString());
}
}
SortData(dc.ColumnName);
}
}
}
This has basically saved the column1 contents of each selected row in an array, so we can later "re-select" the correct rows.
Now add the following code for the SortData method.
private void SortData(string colname)
{
DataRow[] drarray;
drarray = dt.Select(null, colname,
DataViewRowState.CurrentRows);
int len = drarray.Length;
for (int i = 0 ; i < drarray.Length ; i++)
{
DataRow dr = dt.NewRow();
for (int j = 0; j < dt.Columns.Count; j++)
{
dr[j] = drarray[i][j];
}
dt.Rows.Add(dr);
}
for (int i = len - 1 ; i >=0 ; i--)
{
dt.Rows.RemoveAt(i);
}
for (int i = 0; i < dt.Rows.Count; i++)
{
if (al.Contains(dt.Rows[i][0].ToString()))
{
dataGrid1.Select(i);
}
}
}
This sorts the original DataTable into an array, adds the sorted records to the end of the DataTable, then deletes the original ones.
It then checks each row in the DataTable, and if the data in column1 matches the saved data in the ArrayList, it marks the corresponding rows in the DataGrid as "Selected".
Therefore, multiple selected rows are supported.
Limitations:
1. It only supports ascending sorts.
You might want to build a better sort using an IComparer
interface.
2. You lose the little arrows on the column headers.
3. It assumes that the data in Column1 of the DataTable is unique.
You could combine data from more than one column to create a
unique key.
Hopefully this will help get on the right track.
Good luck!
Gary Perkin.
PS I think the Sort Event that the previous respondent was referring to is available in WebForms, but I may be wrong...
|
|
|
|
|
Thank you very much for taking the time to reply.
This is a good start. I think if I replace datatable with dataview I could get it sorted both ways...
Still, I don't understand the usefulness of ability to sort via clicking on column headers, unless you don't want to select a row.
|
|
|
|
|
how can i transfer the data between different forms if that data is created in one form and i need to transfer it to another form within the same application .
Miss With The Best And Die Like The Rest
|
|
|
|
|
I have tried to answer this question on your previous post. There are many ways to achieve what you are trying. First of all, a form is a class like any other ordinary class. Say you have a textbox named text1 which is declared as public within your class Form1 and you use it for letting users write down their username. Then to send its value to a different class, named AnotherClass, from within class Form1 (which is the current form) you could say something like:
AnotherClass myClass = new AnotherClass();
myClass.userName = this.text1.text;
OR
AnotherClass myClass = new AnotherClass(this.text1.text);
Hope this helps
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
i need to store some variables withing one class and that class to be accessible all over my application with the specified common variables as the following
i need when i press button to take the text value from the textbox.text and store that value in global variable within a class which i will use in different forms within the same application .
In addition i tried alot but each time when i declare my class as the following
globalclass myclass = new globalclass();
this.username = myclass.username;
it gives me blank variable in username string
i guess that because i open new instance of that class
but i need to store variables and to be called whenever i want within my application with the variables stored in its places
Any help with that
Thanks .
Miss With The Best And Die Like The Rest
|
|
|
|
|
snouto wrote:
i need when i press button to take the text value from the textbox.text and store that value in global variable
I can't figure out what exactly you are doing wrong here. If you create a class with public variables or, even better, public properties, you shouldn't have problem using it across your forms and application. All you have to do is to create an object of that class and pass those members of it that you need to work with (or the whole object if you need it), as arguments to different classes across your application.
snouto wrote:
In addition i tried alot but each time when i declare my class as the following
globalclass myclass = new globalclass();
this.username = myclass.username;
it gives me blank variable in username string
What value do you initialize the username variable with? Also, what is this.username for? Do you wish to refer to a textbox on the form?
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
my friend i need to store the text box value into
the form username string which i declared in the class of the main form i need that username to be stored in the global class to be accessible with the value of the variable all over my application in different forms
Globalclass myclass = new Globalclass();
myclass.username = textbox.text;
and that myclass.username can be accessed from the globalclass in another form
Miss With The Best And Die Like The Rest
|
|
|
|