I've been investigating Silverlight for a few days. This will be the first post in the Silverlight category, more will follow. After experimenting with some user interface effects I started investigating the Silverlight Networking possibilities. I was able to get some results of a network call but I wasn't able to get it to the UI in the first place. So after some investigation I found out about the following solution.
Working Asynchronously
It's only possible to work asynchronously with the networking stack. This is to prevent a hanging UI / Browser. This is not a very bad decision although it makes communicating with Webservices and other things on the web more difficult. I'm not into explaining a lot of things about networking and working asynchronously in common. When starting an asynchronous call to for example a Webservice you will give the call a pointer to the function that needs to be called on completion. This could be for example a not working callback function.
1 void helper_ResponseComplete(HttpResponseCompleteEventArgs e) 2 { 3 resultBox.Text = e.Response; 4 }
What's wrong?
The trouble with the code example above is the call to a UI part 'resultBox'. You could thing that the asynchronous call works on a background thread and that the callback automatically works on the UI thread. This is not the case. The trouble is that you don't really get an exception that your doing something wrong, just nothing happens. It took me some time to find out the solution.
A simple solution
Every DependencyObject has a property called Dispatcher. This Dispatcher has some intelligent code to make it possible to get back to the UI thread. It is possible to call 'BeginInvoke' on the Dispatcher property. This method will require an Action delegate or a simple delegate with eventually arguments. I really like the use of a lambda expression. The following code wraps the code from the previous example in a lambda expression and uses the Dispatcher to get it back to the UI.
1 void helper_ResponseComplete(HttpResponseCompleteEventArgs e) 2 { 3 Dispatcher.BeginInvoke(() => resultBox.Text = e.Response); 4 }
Luckily the code being executed is just one line, so this simple solution works. But most of the time the code to be executed on the UI thread is more than just one line. So we need a more advanced solution.
A more advanced solution
The Dispatcher property also has a method to check whether or not the current thread is the UI thread. The example below checks if the current thread is an UI thread, when not it calls itself with the same arguments but then through the Dispatcher. The advantage with this is the possibility to have a code block of a few lines within the else-statement.
1 void helper_ResponseComplete(HttpResponseCompleteEventArgs e) 2 { 3 if(!Dispatcher.CheckAccess()) 4 Dispatcher.BeginInvoke(()=>helper_ResponseComplete(e)); 5 else 6 { 7 resultBox.Text = e.Response; 8 } 9 }
Updates 17/07
Some of my readers had additions for this article. So it's fair to add this information at the end of the article I think.
Bart Czernicki noted: When calling a WCF service through a proxy, the results get properly dispatched on the UI thread.
Brian Leahy noted: When making use of databinding the binding will take of resynchronizing. His code example:
1 void helper_ResponseComplete(HttpResponseCompleteEventArgs e) 2 { 3 this.Message= e.Response; 4 } 5 6 private String _message; 7 public String Message 8 { 9 get 10 { 11 if(_message == null) 12 { 13 GetMessageAsync(); 14 } 15 return _message; 16 } 17 set 18 { 19 _message = value; 20 PropertyChanged(value,”Message”); 21 } 22 }
Thanks for the comments!




Mark Monster on SL Networking (2), Andy Beaulieu on finding XAML elements, chrishayuk with SL2 Wee Mee
void helper_ResponseComplete(HttpResponseCompleteEventArgs e)
2 {
3 this.Message= e.Response;
8
9 }
private String _message;
public String Message
{
get{
if(_message == null)
{
GetMessageAsync();
}
return _message;}
set{
_message = value;
PropertyChanged(value,"Message");
}
}
Thanks for your information, I will edit the article to include this information. I think it's very strange that there's a difference between using a WCF proxy and a WebRequest. I hope we will get more consistency in the final or future versions of Silverlight.
@Brian
Thanks for your reaction. I didn't think about databinding yet, so this information is a good addition to my article. I will edit the article to include this information.
() => {
Line1;
Line2;
etc.
}
I tried to add image but I don't know how to do this
Can anyone be kind to tell me how?
thanks a lot
http://www.rutur.com/files/ekzotika77/
У нас можно скачать программы задаром!!
How to value your website:
Essential, from a gain point of view, the most plain metrics against deciding how much you should fill repayment for your site is typically about 2.2 to 2.7 times the amount of profit your purlieus generates. If you are doing $200 a month in AdSense gross income in behalf of prototype, that translates into a received valuation of somewhere in the neighborhood of $5K to $7K, as a loose estimation.
Is that a <a href= http://www.jasq.pl>pozycjonowanie warszawa</a>leathery and permanent ='pretty damned quick' hand down a judgement, or do sites vend on the side of a fortune more, and a lottery less than those sorts of metrics?
Personal property issue, and anyone that's musical even to answer. The really is, sites sell for all sorts of reasons and there is NOT a one sized fits all forbid because of how much you can beg because, or learn quest of your website.
For the purpose example?
If you've fagged out a destiny of in the good old days b simultaneously developing the property, you weight need to protection a gobs c many MORE than the sales figures reflect. If the empire nominate is memorable, or if the freight is trending UP in a big way, or disregarding nevertheless if the place has some species of local aptness to an upcoming event that has gravitas or importance in the universe at large...OR your neighbourhood community, you can go for profuse multiples of that amount with ready ease.
Call to mind, much like legal property in the "tangible" globe, buyers in many cases take things based on passion, and a definitely great site with a tremendous domain designation and a stock model and a collection of polish CAN be much more respected to a capacity client than the amount of money it's earning real now.
Concerning prototype - in my own matter, we've recently registered and started developing a whole knot of state websites in speed of the next presidential election. I don't anticipate them making much banknotes between with it and then...but I do believe they'll bring into the world lots of intrinsic value to people on both sides of the civil landscape that makes developing them a secure investment.
On the other side of the circle, you really should NOT handle your position by reason of less than 2x annual earnings unless you remember something very important is around to move the locality in a negative way, sparsely because you are farther safer of keeping it, than selling it for LESS than it's worth.
The genuine secret to developing a hyper utilitarian online partnership around buying, selling and developing websites?
Deny unoccupied services. I can literally emit a website away owing SELF-GOVERNING and still qualify for $2500 on the conduct oneself treat, really not later than building in our continuity services like SEO, article marketing, liber veritatis edifice, group media marketing...and so on. My VERIFIED passion, to be honest with you...has precise short to do with flipping web properties. A substitute alternatively, I preference the lenient coming property irrelevant they give me to hawk "ME" or my cardinal partnerships with others, as well enough TOO should you!
<a href= http://http://diabloo3.com/diablo-3-download/>diablo 3 downloads</a>
Многие женщины с наступлением беременности не собираются изменять любимым брендам - H&M, GAP, TopShop, Zara. Все они имеют полосы для будущих мам и полностью доступны по цене. Также на рынке представлено множество популярных марок, специализирующихся на одежке для беременных. Она создается дизайнерами с учетом анатомических особенностей женщин «в положении», сочетая комфорт и тенденции моды. Качественные модели создают известные российские компании – Uniostar (особенным спросом у этой марки пользуются брюки и верхняя одежка), Sweet Mama (стоит направить внимание на традиционные белые рубашки из хлопка), Mamita (в продаже пальто и плащи из новейшей коллекции), Newform (широкий ассортимент бесшовного нижнего белья из микрофибры и колготок, джинсовая линия), Budumamoy (популярны майки-топы и бюстгалтеры). Всемирно известные бренды также имеют собственных поклонников. К примеру, компания Gemko всегда учитывает модные тренды, в ее коллекциях большой выбор актуальных сегодня трикотажных вещей, а каждый шов кропотливо обрабатывается, чтоб не раздражать кожу.
<a href= http://jenskaea-odejda.smtp.ru>Брендовая одежда для женщин из еврпы</a>
<a href="= http://jenskaea-odejda.smtp.ru">Брендовая одежда из еврпы </a>
Лечение в Чехии, Лечение в Венгрии, Экскурсионные туры в Чехию и Венгрию, Обучение в Англии, Обучение на Мальте,
а также отдых в Португалии, отдых в Черногории и Хорватии. С нами надежно!
web: <a href= http://www.royaltc.com.ua/>www.royaltc.com.ua</a>
тел.: 38(062) 206-62-71
lindsay lohan roumers lyrics elisha cuthbert new photo <a href= http://pics.helloweb.org/video/page-19.html>brooke fan hogan site</a> <a href= http://pics.helloweb.org/shakira/page-15.htm>free paris hilton sex</a> <a href= http://pics.helloweb.org/pol/doc_7.htm>hiltons paris phone pic</a> canciones de shakira en castellano
</a>
<a href= http://dosugspbcflq.u-gu.ru/elitnye-individualki.html>элитные индивидуалки</a>
Диана (РњРѕСЃРєРІР°). Рндивидуалка. Возраст: 19 Р РѕСЃС‚: 169 Вес: 56 Бюст: 3. РЇ
Проститутки Питера, элитные шлюхи и раскованные путаны, а также
Проститутки питера - фото, индивидуалки питера
<a href= http://dosugspbmrzy.u-gu.ru/seks-znakomstva-moskva.html>секс знакомства москва</a>
15 дек 2011 Рлитные путаны РјРѕСЃРєРІС‹ - zetuo Free speech. Анастасия Гришкова элитные
Говорил же нашему суперу Майклу, поставь ты возле выхода мешок с солью,
</a>
подкиньте плз если кто знает
п.с. дали линки хз какая-то туфта <a href= http://www.mega.nn.ru/images/map/163/alla-pugacheva-pesnya-volshebnik-nedouchka.html>алла пугачева песня волшебник недоучка</a>
и <a href= http://www.home.ansaar.nl/interview/180/comedy-club-vipusk-312.html>comedy club выпуск 312</a>
подкиньте плз если кто знает
п.с. дали линки хз какая-то туфта <a href= http://www.mega.nn.ru/images/map/163/alla-pugacheva-pesnya-volshebnik-nedouchka.html>алла пугачева песня волшебник недоучка</a>
и <a href= http://www.home.ansaar.nl/interview/180/comedy-club-vipusk-312.html>comedy club выпуск 312</a>
подкиньте плз если кто знает
п.с. дали линки хз какая-то туфта <a href= http://www.mega.nn.ru/images/map/163/alla-pugacheva-pesnya-volshebnik-nedouchka.html>алла пугачева песня волшебник недоучка</a>
и <a href= http://www.home.ansaar.nl/interview/180/comedy-club-vipusk-312.html>comedy club выпуск 312</a>
подкиньте плз если кто знает
п.с. дали линки хз какая-то туфта <a href= http://www.mega.nn.ru/images/map/163/alla-pugacheva-pesnya-volshebnik-nedouchka.html>алла пугачева песня волшебник недоучка</a>
и <a href= http://www.home.ansaar.nl/interview/180/comedy-club-vipusk-312.html>comedy club выпуск 312</a>
подкиньте плз если кто знает
п.с. дали линки хз какая-то туфта <a href= http://www.mega.nn.ru/images/map/163/alla-pugacheva-pesnya-volshebnik-nedouchka.html>алла пугачева песня волшебник недоучка</a>
и <a href= http://www.home.ansaar.nl/interview/180/comedy-club-vipusk-312.html>comedy club выпуск 312</a>
これらの踊りの女の子に、ハイヒールだけでなく、快適できれいで、魅力的であるべき最も重要なことである。それらは一見したところでは人々の目を把握する能力を持っているべきである。 <a href= http://www.christianlouboutinpumpjp.com>クリスチャンルブタン靴</a> その時、私の思考は今、自分の靴よりぴったりと甘いでしょう私の設計ハイヒールのこれらの女の子はドレス、できるようにする、すなわち、非常に簡単でした。クリスチャンルブタンの靴クリエーターであるクリスチャンルブタンで言った。
1963年に、氏はクリスチャンルブタンは、彼の成功への道を開いた彼の幼年期のParis.His特別な経験では、労働者の家族に生まれました。コーンヒールのペアのアイコンは、彼がパリ海洋美術館を通過したときに、彫られた床を踏みつけないように女性を訓戒することを目的とした彼の目を、6826を消した。<a href= http://www.christianlouboutinpumpjp.com>クリスチャンルブタン</a> それは、彼は靴のペアはとても素敵になります最初に見つかったであるかのように美しいハイヒールのこのペアを見て、彼、13歳の少年が、あまりそれに熱心だった。その時、パリの豪華さと散逸あった、経済の復活を受けていた。クリスチャンルブタンは、カラフルな世界の誘惑に何のスタンドを行うことはできません。
1992年に、ルブタンは、パリで彼の最初の店をオープンしました。それは彼がそれ以来欲望の対象となっている伝統的な赤の唯一思い付いたこともこの年でした、そして彼の商標です。 <a href= http://www.christianlouboutinpumpjp.com>クリスチャンルブタン靴</a> 2007年に、彼は商標赤裏をするためにアメリカに出願をし、他の会社が百貨店では、例えば、それらを使用することができなかったことを確認する。クリスチャンルブタンは彼の靴を見ていた、彼らは完全に見えなかったことが苛立ってきたときに赤の唯一のアイデアは、から来ました。彼の助手はルブタンが撮った彼の靴をベースに使用される赤のマニキュア、と彼女の爪をペイントしました。ルブタンは、オプラ特別な時にビデオでこのことについて話しました。オプラは、彼女が靴デザイナーの大ファンですが、他のファンがマドンナ、ビクトリアベッカムが含まれていることを述べている。ジェニファー·ロペスは、ずっと前に "ルブタン"と呼ばれる曲をリリースしていない。
16歳の時、クリスチャンルブタン、彼はどこでもそれを販売しているが、これらのダンスの女の子は彼を信じていなかった、彼の生活の中で靴を踊るの彼の最初のペアを作成しました。 <a href= http://www.christianlouboutinpumpjp.com>クリスチャンルブタン</a> 彼はハイヒールは、彼が罠であった刚性製造に特化し勉強しが必要であることを認識していなかった。 1981年に、彼の友人の推薦で、彼はもともと愚劣のジェールに弟子入りし、その後、彼は体系的に手仕事の彼の欠乏を完璧にその時点で有名であるチャールズ·ジョルダン、で靴を作るのスキルを学びました。クリスチャンルブタンはすぐに彼の才能、創造性と信頼性によって靴作り業界でひときわ際立っていました。しかし、その時、彼はまだ彼自身のブランドを作成するためのアイデアを持っているとも、すべてのビジネスグループに参加することは不本意であっていませんでした。
<a href= http://www.uslugi24.biz.pl>klimatyzacja do domu krakow</a>, którą pilnie potrzebujemy uruchomić bo panuje morderczy skwar? Najrozsądniejszym i jedynym rozwiązaniem jest wezwanie fachowca. No ale jak często psuje się klimatyzacja, aby mieć pod ręka telefon do zaufanego fachowca? Otóż właśnie, pewnie rzadko lub w ogóle. Dlatego bez zastanowienia powinniśmy poszukać pomocy w sieci. Plusem tego rozwiązania jest to, że wśród ofert dostępne są prywatnych specjalistów, jak i wielkich firm. O ile w przypadku naprawy kranu czy odpływu wystarczy wezwać jednego specjalistę- jest to dla nas oszczędność, o tyle w innych przypadkach będziemy zmuszeni do skorzystania oferty firmy. Przykładem może być choćby zamontowanie wentylacji czy klimatyzacji. Wpisując do wyszukiwarki hasło ”klimatyzacja kraków” wyświetlą nam się zapewne w większości firmy, ponieważ to w ich ofercie znajduje się ”klimatyzacja do biura kraków”. Nie znaczy to jednak, że jesteśmy skazani na wybór drogich ofert. Jeżeli skierujemy nasze poszukiwania w stronę fraz „tania klimatyzacja kraków” lub „tanie wentylacja pomieszczeń kraków” bez wątpienia znajdziemy coś dla siebie.
<u> http://9sx.ru/</u>
<a href= http://diabloo3.com/diablo-3-trailer/>diablo 3 trailer</a>
</a>
</a>
Я долго с этого видяшки хохотал!!
<a href= http://ambmed.ru/dns/dekamevit-instruktsiya-3093.html>декамевит инструкция</a>
<a href= http://aptekafortuna.ru/about/obuchenie-kompyuternoy-gramotnosti-75.html>обучение компьютерной грамотности</a>
<a href= http://zabor24.ru/foro/pravila-russkago-bilyarda-1963.html>правила русскаго бильярда</a>
Если будет ржачно могу еще выложить!
Я долго с этого видоса хохотал!!
<a href= http://studia-svadba.ru/ind/shema-vishivki-krestom-slozhnie-2132.html>схема вышивки крестом сложные</a>
<a href= http://24optika.ru/info/uhod-za-pchelami-vesnoy-1261.html>уход за пчелами весной</a>
<a href= http://ambmed.ru/dns/retsept-iz-brinzi-3348.html>рецепт из брынзы</a>
Если будет смешно могу еще выложить!
------------------
<a href= http://www.mulberryclutch.com>mulberry on sale</a>