|
For some controls it will work correctly ... most of the time. This is why .Net now catches them and throws and exception, because it is inconsistent and very difficult to catch otherwise.
|
|
|
|
|
I have experienced that it may work without invoke on one machine but it doesn't work on other machines (and took a long time trying to find that out with the assumption that part was not the problem). So it's better to use invoke regardless.
|
|
|
|
|
|
I am fixing to begin writing an app the obvious design is simple however it will most likely not scale very well.
What I am trying to do is have an app that notifies a user when an action needs to be taken.
My initial thought was to have a table that it read based on user and showed new actions.
I will have about 1000+- user hitting this app I want it to be fairly close to real time.
So my question is how are other doing this?
I have read about WCF however it seems convoluted and possibly overkill.
Another thought I had was to have a service running on a server that could send messages out to the other apps it would only need be a one way communication.
Are there other ways to accomplish this?
I have read WCF has quite alot of overhead as well is this correct?
Thank you,
EDIT*** This a winforms app FYI.
Humble Programmer
-- Modified Tuesday, May 10, 2011 1:49 PM
|
|
|
|
|
Unless all 1000+- users are on the same machine, then your app IS a "server".
I'm assuming the users are remote, however, so you need to consider how they will connect to your server app to receive push notifications.
What protocol will you use? For example, TCP/IP using sockets works but do you want every user solidly connected? What happens on disconnects? Who manages the firewall issues? etc...
I personally would use HTTP over TCP/IP. No firewall issues for most clients.
I would also probably use WCF since it comes with HTTP bindings that allow push notifications from a server. Sure you could roll your own HTTP server using IHttpHandler but since HTTP is request/reply and connectionless, you'd have to reinvent code that's already available out of the box with WCF.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Go ahead with WCF as it support TwoWay Bindings so your server can notify your clients.
Overhead to WCF are only to its complex implementation, but at same time it is useful in particular problems.
Search in Google for TwoWay binding in WCF you will get enough resources.
Regards
Rushi
|
|
|
|
|
All,
I have a rather unusual situation, Tried to look for a solution online, but not able to, so I am posting it here.
I have a dataset the loads and fills all the tables during app startup.
When I copy a table and paste it in a notepad I get the following
<?xml version="1.0" encoding="utf-8"?><xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"> <xs:annotation> <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource"> <DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> <ConnectionRefs /> <Connections /> <TableRefs> <DesignTableRef Name="IntersectionPedSignalNotes"> <ColumnRefs /> <SourceRefs /> </DesignTableRef> </TableRefs> <Tables /> <RelationRefs /> <SourceRefs /> <Sources /> </DataSource> </xs:appinfo> </xs:annotation> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="NewDataSet" msprop:Generator_DataSetName="NewDataSet"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="IntersectionPedSignalNotes" msprop:Generator_TableClassName="IntersectionPedSignalNotesDataTable" msprop:Generator_TableVarName="tableIntersectionPedSignalNotes" msprop:Generator_TablePropName="IntersectionPedSignalNotes" msprop:Generator_RowDeletingName="IntersectionPedSignalNotesRowDeleting" msprop:Generator_UserTableName="IntersectionPedSignalNotes" msprop:Generator_RowChangingName="IntersectionPedSignalNotesRowChanging" msprop:Generator_RowEvHandlerName="IntersectionPedSignalNotesRowChangeEventHandler" msprop:Generator_RowDeletedName="IntersectionPedSignalNotesRowDeleted" msprop:Generator_RowEvArgName="IntersectionPedSignalNotesRowChangeEvent" msprop:Generator_RowChangedName="IntersectionPedSignalNotesRowChanged" msprop:Generator_RowClassName="IntersectionPedSignalNotesRow"> <xs:complexType> <xs:sequence> <xs:element name="NoteId" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="-100" msdata:AutoIncrementStep="-1" msprop:Generator_ColumnVarNameInTable="columnNoteId" msprop:Generator_ColumnPropNameInRow="NoteId" msprop:Generator_ColumnPropNameInTable="NoteIdColumn" msprop:Generator_UserColumnName="NoteId" type="xs:int" /> <xs:element name="IntersectionPedSignalId" msprop:Generator_ColumnVarNameInTable="columnIntersectionPedSignalId" msprop:Generator_ColumnPropNameInRow="IntersectionPedSignalId" msprop:Generator_ColumnPropNameInTable="IntersectionPedSignalIdColumn" msprop:Generator_UserColumnName="IntersectionPedSignalId" type="xs:int" /> <xs:element name="Note" msprop:Generator_ColumnVarNameInTable="columnNote" msprop:Generator_ColumnPropNameInRow="Note" msprop:Generator_ColumnPropNameInTable="NoteColumn" msprop:Generator_UserColumnName="Note" type="xs:string" default="" /> <xs:element name="LastUpdated" msprop:Generator_ColumnVarNameInTable="columnLastUpdated" msprop:Generator_ColumnPropNameInRow="LastUpdated" msprop:Generator_ColumnPropNameInTable="LastUpdatedColumn" msprop:Generator_UserColumnName="LastUpdated" type="xs:dateTime" /> <xs:element name="LastUpdatedBy" msprop:Generator_ColumnVarNameInTable="columnLastUpdatedBy" msprop:Generator_ColumnPropNameInRow="LastUpdatedBy" msprop:Generator_ColumnPropNameInTable="LastUpdatedByColumn" msprop:Generator_UserColumnName="LastUpdatedBy" type="xs:string" default="" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> <xs:unique name="Constraint11111111"> <xs:selector xpath=".//IntersectionPedSignalNotes" /> <xs:field xpath="NoteId" /> </xs:unique> </xs:element></xs:schema>
I have a code generator that generates code, and if I use that to generate a different table with the different columns and replace the table name IntersectionPedSignalNotes with IntersectionSignageNotes.
I get the exact same xml code as above, the only difference is the table name. I am hoping to copy this code and paste it in the DataSet so that the new table IntersectionSignageNotes can be created, without me having to add table and columns manually.
Let me know if there are any ideas.
Thanks in advance
Sri
|
|
|
|
|
I'm no DataSet expert at all, and I may be misunderstanding what you said, however it seems to me you want something like:
DataTable table2=table1.Copy();
table2.TableName="table2";
dataset.Tables.Add(table2);
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks, but this is not what I am looking for, I am talking about pasting the xml code when DataSet is opened using "View Designer". Once I copy the xml code generated by code generator and paste it in the DataSet designer window it should create the table.
|
|
|
|
|
OK, can't help you here, I never used the designer for databases.
I can only recommend you edit and clarify your original question so more people may be inclined to reply.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
|
I'm building an application with a 3D render window in the middle of my main form. When the user holds the right mouse button, the cursor is hidden and the mouse is instead used to control the camera within the 3D window. The problem with this is that whilst the cursor is hidden, the mouse is still moving beyond the edge of my window, and eventually I will stop receiving MouseMove events. For this reason I need to set the cursor to it's previous position after handling the MouseMove event.
private void onMouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
prevMousePos = currMousePos;
currMousePos = e.Location;
Point delta = currMousePos - prevMousePos;
Cursor.Position = prevMousePos;
}
}
This won't work because changing the cursor position will cause more MouseMove events to be fired. I thought perhaps I could unsubscribe from the MouseMove event before setting the cursor position, and then resubscribe.
this.panel_RenderWindow.MouseMove -= this.onMouseMove;
Cursor.Position = prevMousePos;
this.panel_RenderWindow.MouseMove += new System.Windows.Forms.MouseEventHandler(this.onMouseMove);
The problem is this doesn't seem to be working correctly. I still get MouseMove events generated from moving the cursor programatically. I have a feeling I'm not unsubscribing the handler correctly. I would check this in the debugger, but I'm unable to find the event in the debugger.
Am I unsubscribing the event correctly, and if I am, is there a reason that this isn't working? Is there a better way to achieve this?
Note: a side-effect of the recursive MouseMove events is that the cursor moves until it gets to the top-left corner of the screen, at which point no further events are generated because the mouse can move no further.
modified on Tuesday, May 10, 2011 9:07 AM
|
|
|
|
|
Simple, use a class-level flag variable.
bool dontTrack = false;
private void EnableMouseTracking() {
dontTrack = false;
}
private void DisableMouseTracking() {
dontTrack = true;
}
private void onMouseMove(object sender, MouseEventArgs e) {
if (!dontTrack) {
}
}
|
|
|
|
|
This doesn't help me. The motivation behind wanting to change the cursor position is that if the user continues dragging the mouse (controlling the 3D camera) whilst the right mouse button is held, then the cursor will eventually leave my window, and I will stop receiving MouseMove events. I need to set the cursor position to the point where the user initiated the drag operation, so that as long as the right mouse button is held, the cursor will remain within my window.
I am aware that very large mouse movements will still be able to free the cursor, but this isn't likely to occur frequently and can be ignored.
|
|
|
|
|
|
Thanks, this sounds like what I'm looking for. There's a minor hitch though, I'm using a Panel control as my render window. It seems that this control doesn't inherit the IInputElement interface required for Mouse.Capture(). My second choice would be a PictureBox control, however that doesn't implement the interface either. Now the question becomes, what control implementing IInputElement can I use that would be suitable for rendering my 3D scene to?
|
|
|
|
|
I'm not familiar with WPF, so I can't help you in any specific way, however a quick glance brought me this sentence, which might help:
In particular, UIElement descends from Visual, which provides the lower-level graphics support for rendering a ContentElement to a rectangular region within a composited window, whereas ContentElement defers rendering so that concepts more common to document scenarios, such as flow and wrapping, are more easily supported. These two related classes also implement the common interfaces IInputElement and IAnimatable.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Back to my initial question, I've spotted a few mistakes which are complicating things a little...
The first mistake was updating prevMousePos to the value in currMousePos, and later using that value to update the position of the cursor.
...
currMousePos = e.Location;
...
The second mistake was assuming that the mouse coordinates in the event were relative to the screen. They are relative to the client rect of the control.
...
Cursor.Position = this.panel_RenderWindow.PointToScreen(prevMousePos);
...
Now the cursor's position is reset correctly, however the problem of the recursive MouseMove events still remains - if I remove Cursor.position = prevMousePos , then my application continues to update in the background, however if I don't everything else freezes until I release the right mouse button - including the 3D render window where the user is expecting to see updates to the camera position. The event is definitely not being unsubscribed correctly, though I can't figure out the correct way.
EDIT: I've been googling for hours and this[^] is the only thread I could turn up that dealt with this specific issue, and the answer he get was less than helpful.
modified on Tuesday, May 10, 2011 11:38 AM
|
|
|
|
|
I'm lost or maybe I missed something, or both.
Why are you programatically moving the mouse cursor if the cursor is hidden? Only because you were not receiving mousemove events if the cursor left the panel, correct?
If so...
Just capture the mouse on the right button down event and release capture on the up event (of course the Panel class has the IInputElement interface needed for the Mouse.Capture() call - how else would you be handling other mouse input on your panel?).
Then your panel will receive all the mouse move events even if the cursor leaves the panel, so you don't have to move the cursor or unsubscribe/subscribe to the event.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In part, yes - I won't receive events when the mouse leaves the panel. That's the theory at least. I've done testing and it seems I still receive events even when the cursor is outside my panel, but when the mouse reaches the edge of the monitor, I will stop receiving MouseMove events, because the cursor will have nowhere further to go. At the moment, the user has to perform multiple click + drag operations to keep the camera rotating over long distances.
The other reason I want this behaviour is that when the right button is released, the mouse will appear in the same place the user initiated the operation, rather than some unexpected location across the screen.
As for IInputElement, I'm no C# expert, but my understanding is that Panel and PictureBox are Winforms controls, whereas IInputElement is a WPF interface. WPF has an Image control (similar to PictureBox, but with different behaviour) that would work well for me, but I can't figure out how to enable WPF controls in my project. All the WPF controls are greyed out. I've added the appropriate references but no luck.
Either way, I'm no longer certain that Mouse.Capture() is what I'm after anyway. Everything I've set out to accomplish here is working, with the exception of unsubscribing the event handler + resubscribing after changing the cursor position.
EDIT: Now I simply do this instead:
private Boolean ignoreMouseMove = false;
private void onMouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
if (!ignoreMouseMove)
{
currMousePos = e.Location;
Point delta = currMousePos - prevMousePos;
Cursor.Position = this.panel_RenderWindow.PointToScreen(prevMousePos);
ignoreMouseMove = true;
}
else
{
ignoreMouseMove = false;
}
}
}
This feels kinda dirty but at least it works. I'd still like to know why unsubscribing the handler wasn't working, if anybody knows the answer.
modified on Tuesday, May 10, 2011 10:19 PM
|
|
|
|
|
Cool.
Sorry about that....I don't know how I thought I was still on the WPF board...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
What is the best way(s) to send strings from java app to .net app?
I have a main c#.net project that runs .jar (java project). The java part must give strings (recognized speech) to the c# part. it's a desktop solution that runs on one computer.
So far I see the following ways to do this:
- use a temporary text file as a buffer;
- sockets;
- windows services;
- web services (imo it's a very bad option);
- free 3d-party tools like ikvm.net and others (tried many, won't work properly, bad option).
Sp what is the best and most effective (and simple) way to do the job?
Thanks.
|
|
|
|
|
I don't know if it qualifies as a socket, but I'd use a Named Pipe.
Named Pipes are used for communication between processes, more info here (wikipedia)[^].
MSDN[^]
I can't find a good article on it (for .Net 3.5) at the moment, I guess I'll have to owe you.
|
|
|
|
|
Thanks! That seems to be a really good thing.
Will the following code work for me?: http://v01ver-howto.blogspot.com/2010/04/howto-use-named-pipes-to-communicate.html
|
|
|
|
|
One way to do this would be to create a wcf service that will be hosted in your main c# app. The Java app can then communicate with the c# app using a known Interface.
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|