<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Yaniv T</title>
	<atom:link href="http://yanivt.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://yanivt.wordpress.com</link>
	<description>The Art of Web Development.</description>
	<lastBuildDate>Tue, 11 Aug 2009 16:32:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='yanivt.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Yaniv T</title>
		<link>http://yanivt.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://yanivt.wordpress.com/osd.xml" title="Yaniv T" />
	<atom:link rel='hub' href='http://yanivt.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Scheduling Tasks in a ASP.NET Application</title>
		<link>http://yanivt.wordpress.com/2009/08/11/scheduling-tasks-in-a-asp-net-application/</link>
		<comments>http://yanivt.wordpress.com/2009/08/11/scheduling-tasks-in-a-asp-net-application/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 16:16:59 +0000</pubDate>
		<dc:creator>yanivt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yanivt.wordpress.com/?p=25</guid>
		<description><![CDATA[Iv&#8217;e more than once run into the need to make a timed, scheduled call to a function, from the context of a ASP.NET web service or application. Lately I discovered a very interesting way to accomplish this task, which is based on the Cache server object and the timeout expiry it provides. The idea in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yanivt.wordpress.com&amp;blog=8949788&amp;post=25&amp;subd=yanivt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Iv&#8217;e more than once run into the need to make a timed, scheduled call to a function, from the context of a ASP.NET web service or application.</p>
<p>Lately I discovered a very interesting way to accomplish this task, which is based on the Cache server object and the timeout expiry it provides.</p>
<p>The idea in general is to insert an object to the cache, set a timeout period for that object equal to how frequent you want your method to be called, and then catch the &#8216;event&#8217; that is raised when the object is disposed from the cache.</p>
<p>So this is how we begin :</p>
<p>Insert that dummy &#8217;timer&#8217; object into the cache when the application starts.<br />
This can be easily accomplished by adding the following code to the Global.asax file of your application</p>
<p> </p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre style="overflow:auto;">    <span style="color:#0000ff;"><span class="kwrd">void</span> </span>Application_Start(<span style="color:#0000ff;"><span class="kwrd">object</span> </span>sender, <span style="color:#008080;">EventArgs </span>e)
    {
        InitiateBackupUtility();
    }

    <span style="color:#0000ff;"><span class="kwrd">private</span> <span class="kwrd">void</span></span> InitiateBackupUtility()
    {
        <span class="kwrd"><span style="color:#0000ff;">if</span></span> (<span class="kwrd"><span style="color:#0000ff;">null</span></span> == <span style="color:#008080;">HttpContext</span>.<span style="color:#000000;">Current</span>.Cache[CacheItem])
        {
<span style="color:#008000;">            <span class="rem">// Add the dummy value to the cache so it would call our timed method when expires</span></span>
            <span style="color:#008080;">HttpContext</span>.Current.Cache.Add(CacheItem, <span class="str"><span style="color:#800000;">"Value"</span></span>, <span class="kwrd"><span style="color:#0000ff;">null</span></span>,
                <span style="color:#008080;">DateTime</span>.MaxValue, <span style="color:#008080;">TimeSpan</span>.FromDays(1),
                <span style="color:#008080;">CacheItemPriority</span>.Normal, <span class="kwrd"><span style="color:#0000ff;">new</span></span> <span style="color:#008080;">CacheItemRemovedCallback</span>(CacheItemRemoved));
        }
    }</pre>
<p> </p>
<p>Now, the code above has registered the callback called &#8216;CacheItemRemoved&#8217; to the expiry of the object.<br />
That is, the method CacheItemRemoved will be called every time our object expires, that is, every time our timer ticks.</p>
<p>Let&#8217;s have a look :</p>
<p> </p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre style="overflow:auto;">    <span style="color:#999999;"><span class="rem">/// &lt;summary&gt;</span>
</span>    <span class="rem"><span style="color:#999999;">///</span> <span style="color:#008000;">This function will be called when the cache item times out </span></span>
    <span class="rem"><span style="color:#999999;">///</span> <span style="color:#008000;">(we don't really care about the parameters for our purpose)</span></span>
    <span style="color:#999999;"><span class="rem">/// &lt;/summary&gt;</span>
</span>    <span style="color:#0000ff;"><span class="kwrd">public</span> <span class="kwrd">void</span></span> CacheItemRemoved(<span class="kwrd">string</span> key, <span class="kwrd">object</span> <span class="kwrd">value</span>,
                                    CacheItemRemovedReason reason)
    {
        <span style="color:#008000;"><span class="rem">// This is your timed function call</span>
</span>        DoWork();

        <span class="rem"><span style="color:#008000;">// This will help us keep the timer ticking</span></span>
        SimulateHttpRequest();
    }</pre>
<p> </p>
<p>Well, keeping the timer ticking is actually a little tricky.<br />
Normally you would expect that we just re-add that item to the cache.<br />
Well, Unfortunately, the HttpContext is only avalible on requests, and this is not a request, but a callback.</p>
<p>Yes, you guessed right. we are going to simulate a Http-Request to our own application.<br />
The good news is, it&#8217;s as simple as that :</p>
<p> </p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre style="overflow:auto;">    <span style="color:#0000ff;"><span class="kwrd">private</span> <span class="kwrd">void</span></span> SimulateHttpRequest()
    {
        System.Net.<span style="color:#008080;">WebClient </span>wc = <span class="kwrd"><span style="color:#0000ff;">new</span></span> System.Net.WebClient();
        wc.DownloadData(appDomain + <span class="str"><span style="color:#800000;">"RestoreCacheItem.aspx"</span></span>);
    }
<span style="color:#0000ff;"> </span>
    <span class="kwrd"><span style="color:#0000ff;">void</span></span> Application_BeginRequest(<span class="kwrd"><span style="color:#0000ff;">object</span></span> sender, <span style="color:#008080;">EventArgs</span> e)
    {
        <span class="kwrd"><span style="color:#0000ff;">if</span></span> (Request.Url.AbsoluteUri == appDomain + <span class="str"><span style="color:#800000;">"RestoreCacheItem.aspx"</span></span>)
        {
            InitiateBackupUtility();
        }
    }</pre>
<p> </p>
<p>You see, the Application_BeginRequests catches our request to that false page, and calls the method that enters that timer key into the cache again, now, all you have to do is provide <strong>appDomain, </strong>which is a string containing the absolute path to your application.</p>
<p>Enjoy!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yanivt.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yanivt.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yanivt.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yanivt.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yanivt.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yanivt.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yanivt.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yanivt.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yanivt.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yanivt.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yanivt.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yanivt.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yanivt.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yanivt.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yanivt.wordpress.com&amp;blog=8949788&amp;post=25&amp;subd=yanivt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yanivt.wordpress.com/2009/08/11/scheduling-tasks-in-a-asp-net-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ac54e0be7c7abf77e5f9f65128ba671c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yanivt</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding confirm behaviour to GridView&#8217;s delete button</title>
		<link>http://yanivt.wordpress.com/2009/08/10/adding-confirm-behaviour-to-gridviews-delete-button/</link>
		<comments>http://yanivt.wordpress.com/2009/08/10/adding-confirm-behaviour-to-gridviews-delete-button/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 18:24:05 +0000</pubDate>
		<dc:creator>yanivt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yanivt.wordpress.com/?p=9</guid>
		<description><![CDATA[Adding confirmation functionality to the ASP.NET GridView control is quite simple, as it turns out after i struggled with it a bit. Making the ASP.NET GridView confirm on delete : 1. Catch the RowDataBound event of your GridView. 2. Check if the currently added row is a data row 3. Add the confirm behaviour to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yanivt.wordpress.com&amp;blog=8949788&amp;post=9&amp;subd=yanivt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Adding confirmation functionality to the ASP.NET GridView control is quite simple, as it turns out after i struggled with it a bit.</p>
<p><span style="text-decoration:underline;">Making the ASP.NET GridView confirm on delete :</span></p>
<p>1. Catch the RowDataBound event of your GridView.<br />
2. Check if the currently added row is a data row<br />
3. Add the confirm behaviour to your LinkButton Attributes.</p>
<p>code :</p>
<pre style="overflow:auto;background-color:#FFFFFF;font-size:small;color:black;font-family:Courier New;"><span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> MyGridView_RowDataBound(<span style="color:#0000ff;">object</span> sender, GridViewRowEventArgs e)
{
<span style="color:#008000;">   // Check that the current row is a real data row</span>
<span style="color:#0000ff;">   if</span> (e.Row.RowType == DataControlRowType.DataRow)
   {
<span style="color:#008000;">      // Adding the onclick attribute to the delete link - 3 is the delete button index.</span>
      (MyGridView.Rows[e.Row.RowIndex].Cells[3].Controls[0] <span style="color:#0000ff;">as</span> LinkButton).
      Attributes.Add(<span style="color:#A31515;">"onclick"</span>, <span style="color:#A31515;">"return confirm('Are You Sure?');"</span>);
   }
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yanivt.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yanivt.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yanivt.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yanivt.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yanivt.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yanivt.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yanivt.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yanivt.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yanivt.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yanivt.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yanivt.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yanivt.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yanivt.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yanivt.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yanivt.wordpress.com&amp;blog=8949788&amp;post=9&amp;subd=yanivt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yanivt.wordpress.com/2009/08/10/adding-confirm-behaviour-to-gridviews-delete-button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ac54e0be7c7abf77e5f9f65128ba671c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yanivt</media:title>
		</media:content>
	</item>
		<item>
		<title>You are looking for something that isn&#8217;t there</title>
		<link>http://yanivt.wordpress.com/2009/08/10/you-are-looking-for-something-that-isnt-there/</link>
		<comments>http://yanivt.wordpress.com/2009/08/10/you-are-looking-for-something-that-isnt-there/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 17:53:57 +0000</pubDate>
		<dc:creator>yanivt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yanivt.wordpress.com/?p=3</guid>
		<description><![CDATA[I started a blog on wordpress. I wonder if mentioning that i&#8217;m not the typical blogger, or that i never thought i would start one myself, would sound too banal. I can&#8217;t even figure out the reason i made a decision to start one. I&#8217;m not willing to admit that I&#8217;m seeking acknowledgement for anything [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yanivt.wordpress.com&amp;blog=8949788&amp;post=3&amp;subd=yanivt&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I started a blog on wordpress.</p>
<p>I wonder if mentioning that i&#8217;m not the typical blogger, or that i never thought i would start one myself, would sound too banal. I can&#8217;t even figure out the reason i made a decision to start one.</p>
<p>I&#8217;m not willing to admit that I&#8217;m seeking acknowledgement for anything that i encounter in my private life, I actually didn&#8217;t quite feel like anyone is going to read any of this, until the moment i started typing the first word of this very first post.</p>
<p>On the other hand, I can&#8217;t actually convince myself that I&#8217;m not seeking recognition among other web developers, and to broaden my professional and eventually business-related world.</p>
<p>What i&#8217;m trying to say is &#8211; I started a blog while definitely looking for something.</p>
<p>And here I am &#8211; looking at my brand new wordpress blog page that has nothing in it but the following sentence :</p>
<p><strong>Sorry, You are looking for something that isn&#8217;t there.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yanivt.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yanivt.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yanivt.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yanivt.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yanivt.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yanivt.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yanivt.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yanivt.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yanivt.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yanivt.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yanivt.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yanivt.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yanivt.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yanivt.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yanivt.wordpress.com&amp;blog=8949788&amp;post=3&amp;subd=yanivt&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yanivt.wordpress.com/2009/08/10/you-are-looking-for-something-that-isnt-there/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ac54e0be7c7abf77e5f9f65128ba671c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">yanivt</media:title>
		</media:content>
	</item>
	</channel>
</rss>
