<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Timer in Browser form</title><link>https://www.infopathdev.com:443/forums/thread/25647.aspx</link><pubDate>Mon, 14 Jan 2008 19:47:12 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:25647</guid><dc:creator>davidair</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/25647.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=25647</wfw:commentRss><description>&lt;p&gt;Hey Chris,&lt;/p&gt;
&lt;p&gt;Forms Server business logic runs only on the server during the postback. So if a postback was not initiated by the user you cannot really do anything. Consider this:&lt;/p&gt;
&lt;p&gt;- A user clicks a button&lt;br /&gt;- The form is submitted to the server and your code runs&lt;br /&gt;- Your code sets a timer, then FormsServer finishes rendering the form and sends it back to the client&lt;/p&gt;
&lt;p&gt;- Some time later, your timer fires... by this time the window where you were allowed to modify the data source has long ago gone because for the Formsserver persective it is done servicing the request and you have no more business modifying anything.&lt;/p&gt;
&lt;p&gt;So this approach would not work. What you can do instead is to host your form in a custom ASPX page and have some Javascript code to cause periodic postbacks of the entire page. This has a significant drawback though - it will result in weird user experience and potential data loss (imagine you&amp;#39;re typing some text and suddenly the page does a postback and you&amp;#39;ve lost what you have typed... what if it was a large rich-text field?)&lt;/p&gt;
&lt;p&gt;If your locking mechanism is external to the form you can use AJAX to maintain the lock without refreshing the entire page, you might need to write a separate web service for that.&lt;/p&gt;
&lt;p&gt;Dave.&lt;/p&gt;</description></item><item><title>Re: Timer in Browser form</title><link>https://www.infopathdev.com:443/forums/thread/25635.aspx</link><pubDate>Mon, 14 Jan 2008 15:49:20 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:25635</guid><dc:creator>Matt Faus</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/25635.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=25635</wfw:commentRss><description>&lt;p&gt;Hi anotherchrisberry,&lt;/p&gt;
&lt;p&gt;At least the timer function is working correctly!&amp;nbsp; I&amp;#39;m not too familiar with IP07 OM code, but why do you need a reference to the Main DOM?&amp;nbsp; I would think that you need to call the Submit() method on one of your data source connection objects.&lt;/p&gt;</description></item><item><title>Timer in Browser form</title><link>https://www.infopathdev.com:443/forums/thread/25521.aspx</link><pubDate>Wed, 09 Jan 2008 21:43:53 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:25521</guid><dc:creator>anotherchrisberry</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/25521.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=25521</wfw:commentRss><description>&lt;p&gt;I assume this is not possible but want to make sure before I give up:&lt;/p&gt;&lt;p&gt;I want to automatically submit a form every five minutes while it&amp;#39;s open in the browser. I do this to maintain a &amp;quot;lock&amp;quot; on the form, which is actually rendered as a secondary data source in another form.&lt;/p&gt;&lt;p&gt;I was hoping to use System.Timers, but I can&amp;#39;t access the MainDataSource. Below is the code I&amp;#39;m trying to use, calling it from a button:&lt;/p&gt;&lt;p&gt;&amp;nbsp;public void btnOpenIntro_Clicked(object sender, ClickedEventArgs e) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timer aTimer = new Timer(10000);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aTimer.Interval = 2000;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aTimer.Enabled = true;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;public void OnTimedEvent(object source, ElapsedEventArgs e) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XPathNavigator xpxp = MainDataSource.CreateNavigator();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;When the code reaches the last line in OnTimedEvent, it returns an UnhandledOperationException: &amp;quot;Operation is not valid due to the current state of the object.&amp;quot;&lt;/p&gt;&lt;p&gt;Any suggestions? I&amp;#39;m pretty new to C#.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>