Click here to Skip to main content
15,890,897 members
Home / Discussions / C#
   

C#

 
AnswerRe: Debugging: Stepping into Entity Framework Pin
Dave Kreskowiak25-Feb-16 5:06
mveDave Kreskowiak25-Feb-16 5:06 
GeneralRe: Debugging: Stepping into Entity Framework Pin
Sascha Lefèvre25-Feb-16 5:21
professionalSascha Lefèvre25-Feb-16 5:21 
GeneralRe: Debugging: Stepping into Entity Framework Pin
Dave Kreskowiak25-Feb-16 5:41
mveDave Kreskowiak25-Feb-16 5:41 
GeneralRe: Debugging: Stepping into Entity Framework Pin
Sascha Lefèvre25-Feb-16 6:07
professionalSascha Lefèvre25-Feb-16 6:07 
GeneralRe: Debugging: Stepping into Entity Framework Pin
Sascha Lefèvre25-Feb-16 8:45
professionalSascha Lefèvre25-Feb-16 8:45 
GeneralRe: Debugging: Stepping into Entity Framework Pin
Dave Kreskowiak25-Feb-16 9:25
mveDave Kreskowiak25-Feb-16 9:25 
GeneralRe: Debugging: Stepping into Entity Framework Pin
Sascha Lefèvre25-Feb-16 9:59
professionalSascha Lefèvre25-Feb-16 9:59 
QuestionRx SubscribeOn and ObserveOn Pin
Kenneth Haugland24-Feb-16 20:02
mvaKenneth Haugland24-Feb-16 20:02 
I'm using the NuGet packages rx-main and rx-xaml in my code.

I was basically just reading up on the subject
MSDN Blogs[^], but some of the examples[^] just confused me more than they clarified.

What I (think?) learned were that if you subscribed on the same thread as the never ending function while observing on a different thread, your subscription code would execute. But if I commented out the SubscribeOn code from the example:
//.SubscribeOn(Scheduler.CurrentThread)
.ObserveOn(Scheduler.Default)

It had the exact same effect as if it was there. The subscription seem to run on the same thread as the ObserveOn. So what was the point of SubscribeOn exactly? The problem is that I cant really see any use for it as of now.

IF I wanted to execute something on a different thread I could do this, an example from [WP7Dev] Using the WebClient with Reactive Extensions for Effective Asynchronous Downloads[^]:
C#
public IObservable<string> StartDownload(string uri)
      {
          WebClient wc = new WebClient();

          var o = Observable.FromEventPattern<DownloadStringCompletedEventArgs>(wc, "DownloadStringCompleted")

                            // Let's make sure that we're not on the UI Thread
                            .ObserveOn(Scheduler.Default)

                            // When the event fires, just select the string and make
                            // an IObservable<string> instead
                            .Select(newString => ProcessString(newString.EventArgs.Result));

          wc.DownloadStringAsync(new Uri(uri));

          return o;
      }

      public string ProcessString(string s)
      {
          // A very very very long computation
          Thread.Sleep(3000);
          return s + "<!-- Processing End -->";
      }

      //http://jaylee.org/post/2010/06/22/WP7Dev-Using-the-WebClient-with-Reactive-Extensions-for-Effective-Asynchronous-Downloads.aspx
      public void DisplayMyString()
      {
          var asyncDownload = StartDownload("http://bing.com");
          var asyncDownload2 = StartDownload("http://google.com");

          // Take both results and combine them when they'll be available
          var zipped = asyncDownload.Zip(asyncDownload2, (left, right) => left + " - " + right);

          // Now go back to the UI Thread
          zipped.ObserveOnDispatcher().SubscribeOnDispatcher()

                // Subscribe to the observable, and set the label text
                .Subscribe(s => label.Text = s);
      }

I put SubscribeOnDispatcher in as a test, but it is not needed. Am I missing something here, or is the SubscribeOnDispatcher totally useless?
AnswerRe: Rx SubscribeOn and ObserveOn Pin
Pete O'Hanlon25-Feb-16 0:13
mvePete O'Hanlon25-Feb-16 0:13 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Kenneth Haugland25-Feb-16 1:42
mvaKenneth Haugland25-Feb-16 1:42 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Pete O'Hanlon25-Feb-16 2:05
mvePete O'Hanlon25-Feb-16 2:05 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Kenneth Haugland25-Feb-16 2:31
mvaKenneth Haugland25-Feb-16 2:31 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Pete O'Hanlon25-Feb-16 2:34
mvePete O'Hanlon25-Feb-16 2:34 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Kenneth Haugland25-Feb-16 4:38
mvaKenneth Haugland25-Feb-16 4:38 
SuggestionRe: Rx SubscribeOn and ObserveOn Pin
Matt T Heffron25-Feb-16 10:26
professionalMatt T Heffron25-Feb-16 10:26 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Kenneth Haugland25-Feb-16 10:33
mvaKenneth Haugland25-Feb-16 10:33 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Kenneth Haugland25-Feb-16 20:27
mvaKenneth Haugland25-Feb-16 20:27 
AnswerRe: Rx SubscribeOn and ObserveOn Pin
Matt T Heffron26-Feb-16 7:20
professionalMatt T Heffron26-Feb-16 7:20 
GeneralRe: Rx SubscribeOn and ObserveOn Pin
Kenneth Haugland25-Feb-16 20:55
mvaKenneth Haugland25-Feb-16 20:55 
QuestionIssue with retrieving items from an IEnumerable<T> Pin
RichardGrimmer24-Feb-16 3:27
RichardGrimmer24-Feb-16 3:27 
SuggestionRe: Issue with retrieving items from an IEnumerable<T> Pin
Richard Deeming24-Feb-16 3:50
mveRichard Deeming24-Feb-16 3:50 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
RichardGrimmer24-Feb-16 4:23
RichardGrimmer24-Feb-16 4:23 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
Richard Deeming24-Feb-16 4:34
mveRichard Deeming24-Feb-16 4:34 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
RichardGrimmer24-Feb-16 4:44
RichardGrimmer24-Feb-16 4:44 
GeneralRe: Issue with retrieving items from an IEnumerable<T> Pin
Pete O'Hanlon24-Feb-16 5:06
mvePete O'Hanlon24-Feb-16 5:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.