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

Pause UsbDetector during uploading #372

Merged
merged 6 commits into from
Jul 20, 2017
Merged

Pause UsbDetector during uploading #372

merged 6 commits into from
Jul 20, 2017

Conversation

codeworm96
Copy link
Contributor

Pause UsbDetector during uploading, so that the resetting of board during uploading will not trigger an annoying display of the board's README.

@msftclas
Copy link

@codeworm96,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla.microsoft.com.

It will cover your contributions to all Microsoft-managed open source projects.
Thanks,
Microsoft Pull Request Bot

@msftclas
Copy link

@codeworm96,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@@ -106,6 +117,20 @@ export class UsbDetector {
}
}

public pauseListening() {
if (this._usbDetector) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we resume the existing stopListening/startListening? The two new APIs seems duplicate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact, it is possible but the startListening() method needs to be modified. The current startListening() just sets the add event listener and does not explicitly start listening. It works previously just because the detector is default to be listening after initialization. startListening() cannot switch back the status of detector correctly yet.

My concern is that it may be unnecessary to set the add event listener again and again.

src/extension.ts Outdated
@@ -184,8 +183,8 @@ export async function activate(context: vscode.ExtensionContext) {
const completionProvider = new CompletionProvider();
context.subscriptions.push(vscode.languages.registerCompletionItemProvider(ARDUINO_MODE, completionProvider, "<", '"', "."));

usbDetector = new UsbDetector(context.extensionPath);
usbDetector.startListening();
UsbDetector.extensionRoot = context.extensionPath;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can add Initialize(extensionRoot : string) method to UsbDector instance for passing value but not use the module to pass object value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good advice.


public static getInstance(): UsbDetector {
if (!UsbDetector._instance) {
UsbDetector._instance = new UsbDetector(UsbDetector.extensionRoot);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should check the extensionRoot value carefully since there is no any explicit of the sequence of the calling order

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure what behavior should be if the assumption is violated. Can you give me some advice?

@yaohaizh yaohaizh merged commit f6e5343 into master Jul 20, 2017
@codeworm96 codeworm96 deleted the feature/pause-detector branch September 22, 2017 06:57
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.

3 participants