Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

GH-156 Create new queue if null queue #157

Merged
merged 2 commits into from
Apr 9, 2018
Merged

Conversation

jamesmontemagno
Copy link
Collaborator

via: https://stackoverflow.com/questions/33642590/nsoperationqueue-currentqueue-not-working

Description of Change

If the current queue is null because it is being called from an outside context then create a new one :)

Bugs Fixed

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Updated documentation (see walkthrough)

@@ -57,5 +57,8 @@ internal static UIViewController GetCurrentViewController(bool throwIfNull = tru

internal static CMMotionManager MotionManager =>
motionManager ?? (motionManager = new CMMotionManager());

internal static NSOperationQueue CurrentQueue =>
NSOperationQueue.CurrentQueue ?? new NSOperationQueue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just have to remember (or maybe make a note) that this is going to fail:

var myThing = DoSomething(Platform.CurrentQueue);

if (myThing.Queue == Platform.CurrentQueue) {
    // in my mind
} else {
    // say whaa?!?
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should change this from a property to a method like Platform.GetQueue() or something that indicates that it does not return the same object in some cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, this is internal so a comment may be just fine as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i like get queue so it doesn't think it is always the same. Good call.

@jamesmontemagno jamesmontemagno merged commit aebf3b1 into master Apr 9, 2018
@jamesmontemagno jamesmontemagno deleted the bug/issue-156 branch April 9, 2018 18:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants