|
There's no such thing as the "final HTML". Documents can be modified by any number of scripts and by any number of actions on the web page and at any time AFTER the document complete events fire. Click a button and a DIV might disappear. There's no way to tell.
Your concept of a "final HTML" just doesn't exist, even more so today with more script, Flash, AJAX, HTML5, ... HTML is far from a static entity.
|
|
|
|
|
|
Hi guys,
First of all - I am not very experienced. I have the following strage situation:
Task t = null;
t = Task.Factory.StartNew(() =>
{
while (true)
{
// do some calculations
LogToUi("some result");
Thread.Sleep(15000);
}
});
LogToUi is a function that updates a textbox in the UI. It does it pretty straightforward tbUpdateMe.Text = passedtoLogToUiText;
This works just fine, it also works if I use a listbox instead of textbox, but If I would like to change LogToUi to update a datagridview - it does not work.
I was told that in general what I have written should not work.... But it does... So why?
A friend of mine told me that even with textbox it should not work... But it does... So what is the situation and can I expect that it will work with TextBox but not very stable or what?
|
|
|
|
|
So long as your LogToUi method is invoking to the UI thread then any control can be updated successfully. If not, you will end up with illegal cross thread exceptions, or your app may crash (eventually!) if you have these turned off.
|
|
|
|
|
Invoke is required, here[^] is more about it.
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.
modified on Tuesday, May 10, 2011 5:56 PM
|
|
|
|
|
|
Thanks. I accidentally provided the link to my local copy... Fixed it.
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 Alan.
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.
|
|
|
|
|
Yeah, I'm surprised it ever works like that. Maybe you get lucky every once in a while and the task is scheduled on the UI thread...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
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.
|
|
|
|
|