GetPageContent method takes 10 - 15 seconds to run

Hi,
I'm writing a OneNote 2010 Add-In using C#, and a call to getPageContent takes between 10 and 15 seconds to run, during which OneNote does not respond to user interaction. The page whose content I'm getting is somewhat large -- it has
a single table with 2 columns and roughly 1,500 rows, with roughly 10,000 words total from across the table.
I'm running getPageContent in its own thread, but this doesn't seem to help. OneNote doesn't appear to respond to user input while the method is running, no matter what thread the method is called from within (as far as I can tell).
The notebook is on a remote SharePoint server, but the issue remains even when working offline. 
Below is my code (pared down to isolate the issue), the line in question in bold.
Any ideas how I could speed this up, or if I'm doing something wrong in general (I'm fairly new to C# / add-in development)?
Thanks in advance,
Neil 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Extensibility;
using Microsoft.Office.Interop.OneNote;
using Microsoft.Office.Core;
using System.Windows.Forms;
using System.Runtime.InteropServices.ComTypes;
using System.Drawing.Imaging;
using System.IO;
using System.Xml.Linq;
using System.Threading;
namespace NeilOneNote
[GuidAttribute("8C1483FF-EEDD-4658-9D17-6BCE348106BF"),ProgId("NeilOneNote.Class1")]
public class Class1 : IDTExtensibility2, IRibbonExtensibility
ApplicationClass onApp = new ApplicationClass();
public void OnAddInsUpdate(ref Array custom)
public void OnBeginShutdown(ref Array custom)
if (onApp != null)
onApp = null;
public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
onApp = (ApplicationClass)Application;
public void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
onApp = null;
GC.Collect();
GC.WaitForPendingFinalizers();
public void OnStartupComplete(ref Array custom)
public string GetCustomUI(string RibbonID)
return Properties.Resources.ribbon;
public void showHello(IRibbonControl control)
ThreadStart childref = new ThreadStart(createLinks);
Thread childThread = new Thread(childref);
childThread.Start();
public void createLinks()
string notebookXml;
onApp.GetHierarchy(null, HierarchyScope.hsPages, out notebookXml);
var destinationDoc = XDocument.Parse(notebookXml);
var destinationNs = destinationDoc.Root.Name.Namespace;
var destinationPageSection = destinationDoc.Descendants(destinationNs + "Section").Where(n => n.Attribute("name").Value == "Lists").FirstOrDefault();
var destinationPageNode = destinationPageSection.Descendants(destinationNs + "Page").Where(n => n.Attribute("name").Value == "Words").FirstOrDefault();
if (destinationPageNode != null)
var destinationPageId = destinationPageNode.Attribute("ID").Value;
string destinationPageContent;
onApp.GetPageContent(destinationPageId, out destinationPageContent, PageInfo.piBasic);
public IStream GetImage(string imageName)
MemoryStream mem = new MemoryStream();
Properties.Resources.HelloWorld.Save(mem, ImageFormat.Png);
return new CCOMStreamWrapper(mem);

Hi,
Since we are not the best resource for coding, if you need assistance regarding C#, I'd recommend you post your question in the following forum:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=csharpgeneral
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
Steve Fan
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs.
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected]

Similar Messages

  • OneNote getPageContent method takes 10 - 15 seconds to run

    Hi,
    I originally posted this under "Office 2010 - IT Pro General Discussions" but the moderator suggested I move it here.
    I'm writing a OneNote 2010 Add-In using C# and
    Microsoft.Office.Interop.OneNote, and a call to getPageContent takes
    between 10 and 15 seconds to run, during which OneNote does not respond to user interaction. The page whose content I'm getting is somewhat large -- it has a single table with 2 columns and roughly 1,500 rows, with roughly 10,000 words total from across
    the table.
    I'm running getPageContent in its own thread, but this doesn't seem to help. OneNote doesn't appear to respond to user input while the method is running, no matter what thread the method is called from within (as far as I can tell).
    The notebook is on a remote SharePoint server, but the issue remains even when working offline. 
    Below is my code (pared down to isolate the issue), the line in question in bold.
    Any ideas how I could speed this up, or if I'm doing something wrong in general (I'm fairly new to C# / add-in development)?
    Thanks in advance,
    Neil 
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Runtime.InteropServices;
    using Extensibility;
    using Microsoft.Office.Interop.OneNote;
    using Microsoft.Office.Core;
    using System.Windows.Forms;
    using System.Runtime.InteropServices.ComTypes;
    using System.Drawing.Imaging;
    using System.IO;
    using System.Xml.Linq;
    using System.Threading;
    namespace NeilOneNote
    [GuidAttribute("8C1483FF-EEDD-4658-9D17-6BCE348106BF"),ProgId("NeilOneNote.Class1")]
    public class Class1 : IDTExtensibility2, IRibbonExtensibility
    ApplicationClass onApp = new ApplicationClass();
    public void OnAddInsUpdate(ref Array custom)
    public void OnBeginShutdown(ref Array custom)
    if (onApp != null)
    onApp = null;
    public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
    onApp = (ApplicationClass)Application;
    public void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
    onApp = null;
    GC.Collect();
    GC.WaitForPendingFinalizers();
    public void OnStartupComplete(ref Array custom)
    public string GetCustomUI(string RibbonID)
    return Properties.Resources.ribbon;
    public void showHello(IRibbonControl control)
    ThreadStart childref = new ThreadStart(createLinks);
    Thread childThread = new Thread(childref);
    childThread.Start();
    public void createLinks()
    string notebookXml;
    onApp.GetHierarchy(null, HierarchyScope.hsPages, out notebookXml);
    var destinationDoc = XDocument.Parse(notebookXml);
    var destinationNs = destinationDoc.Root.Name.Namespace;
    var destinationPageSection = destinationDoc.Descendants(destinationNs + "Section").Where(n => n.Attribute("name").Value == "Lists").FirstOrDefault();
    var destinationPageNode = destinationPageSection.Descendants(destinationNs + "Page").Where(n => n.Attribute("name").Value == "Words").FirstOrDefault();
    if (destinationPageNode != null)
    var destinationPageId = destinationPageNode.Attribute("ID").Value;
    string destinationPageContent;
    onApp.GetPageContent(destinationPageId, out destinationPageContent, PageInfo.piBasic);
    public IStream GetImage(string imageName)
    MemoryStream mem = new MemoryStream();
    Properties.Resources.HelloWorld.Save(mem, ImageFormat.Png);
    return new CCOMStreamWrapper(mem);

    Hi JukeBox,
    According to the description, the Application.GetPageContent cost much time when the page is large and this operation will lead to the OneNote unresponsive.
    Based on my understanding, it is expected since the page is large. And the reaseon that for the OneNote application is unresponsive prevents users operating OneNote make the page content is not the latest.
    As a workaournd, we can copy the table into a spreadsheet and attach this file on OneNote to make the page is small.
    Hope it is helpful.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • I'm on Firefox 3.6.8 running on a 2008 IMAC with OS 10.5.8 yet every click to move pages, from start-up, to return to Home Page takes minutes, not seconds! If I use Safari that's greatly faster on this same set-up. How do I get Firefox to be as fast ?

    I'm on Firefox 3.6.8 running on a 2008 IMAC with OS 10.5.8 yet every click to move pages, from start-up, to return to Home Page takes minutes, not seconds! If I use Safari that's greatly faster on this same set-up. How do I get Firefox to be as fast ?
    == Some time back, beggining with Firefox updates, at least three, or more updates ago.

    Thanks for the tip. I took the following steps:
    1) Backed up the existing profile (presumably corrupted somewhere);
    2) Deleted the existing profile;
    3) Moved the existing Firefox to the Trash and downloaded a fresh copy;
    4) Started Firefox (thus allowing it to create its default profile)
    5) Copied the following files from the backup copy of the previous profile: places.sqlite, key3.db, signons.sqlite, permissions.sqlite, persdict.dat, cert8.db ---
    I'm posting this from a Firefox browser, so I guess I'm OK now.

  • HT6058 I have updated my I pad dut I'm still having problems my iPad seems to freeze and when I go to put in my pin it take a few seconds before the numbers go in and my games stop and start and stop and start for a bit before they run properly

    I have updated my I pad dut I'm still having problems my iPad seems to freeze and when I go to put in my pin it take a few seconds before the numbers go in and my games stop and start and stop and start for a bit before they run properly

    Try this  - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.) No data/files will be erased.
     Cheers, Tom

  • Why the 'LIKE' operator takes so much time to run?

    I have a table T with 3 columns and 3 indexes:
    CREATE TABLE T
    id VARCHAR2(38) NOT NULL,
    fid VARCHAR2(38) NOT NULL,
    val NVARCHAR2(2000) NOT NULL
    ALTER TABLE T ADD (CONSTRAINT pk_t PRIMARY KEY (id,fid));
    CREATE INDEX t_fid ON T(fid);
    CREATE INDEX t_val ON T(val);
    Then I have the following two queries which differ in only one place - the 1st one uses the '=' operator whereas the 2nd uses 'LIKE'. Both queries have the identical execution plan and return one identical row. However, the 1st query takes almost 0 second to execute, and the 2nd one takes more than 12 seconds, on a pretty beefy machine. I had played with the target text, like placing '%' here and/or there, and observed the similar timing every time.
    So I am wondering what I should change to make the 'LIKE' operator run as fast as the '=' operator. I know CONTEXT/CATALOG index is a viable approach, but I am just trying to find out if there is a simpler alternative, such as a better use of the index t_val.
    1) Query with '=' operator
    SELECT id
    FROM T
    WHERE fid = '{999AE6E4-1ED9-459B-9BB0-45C913668C8C}'
    AND val = '3504038055275883124';
    2) Query with 'LIKE' operator
    SELECT id
    FROM T
    WHERE fid = '{999AE6E4-1ED9-459B-9BB0-45C913668C8C}'
    AND val LIKE '3504038055275883124';
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=1 Card=1 Bytes=99)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T' (Cost=1 Card=1 Bytes=99)
    2 1 INDEX (RANGE SCAN) OF 'T_VAL' (NON-UNIQUE) (Cost=4 Card=12)

    I will for sure try to change the order of the PK and see whether there will be any impact to the performance.
    In our application, val is much closer to a unique value than fid. In the example query, the execution plan showed that the index on val was indeed used in the execution of the query. That's why the 1st query took almost no time to return (our table T has more than 6 million rows).
    I was hoping the 'LIKE' operator would utilize the t_val index effectively and provide similar performance to the '=' operator. But apparently that's not the case, or needs some tricks.

  • Free Busy takes over 30 seconds to retrieve on Outlook 2010 using Exchange Server 2010

    We have a small 100 user domain running Exchange server 2010 and outlook 2010 clients.  The issue is that Retrieving Free/Busy takes over 30 seconds.  
    So someone is trying to schedule a meeting has to wait Minutes see the Free/busy time for many users..  I have checked and all the users in question have published at least one month free busy time.
    It seems it would be much faster.  Anyone have this same experience and know of a way to speed it up?
    thanks in Advance
    David 

    Hi David,
    Does the issue happen in OWA? In Exchange 2010, the free/busy information is retreved by using Availability service (EWS url). Generally, if a user wants to view free/busy information when create a meeting, the http Availability service request
    would send to CAS server.
    Please check whether the usage in Exchange server is high when the slow free/busy information occurs. This reflect time would also be related to the network in your environment.
    Regards,
    Winnie Liang
    TechNet Community Support

  • Firefox 4.0 takes about 60 seconds to start even after reinstalling.

    Firefox 4.0 takes about 60 seconds to start. I have tried reinstalling with no change. It isn't antivirus software, as I turned that off and it was still slow. I run Vista Ultimate. Internet Explorer loads very quickly.

    I wish my Firefox would load in 16 seconds!! It takes 3 to 4 mins to load but closes almost instantly.

  • Mail Preferences takes 10 - 120 seconds to open

    OSX Apple Mail Preferences takes 10 - 120 seconds to open when Accounts is selected.  If General or anything other than Accounts is selected it's as quick as can be.
    5 imaps, 1 pop and 1 inactive pop
    Repaired Permissions 5x
    Verify Disk OK
    Processor  2.5 GHz Intel Core i5
    Memory  20 GB 1333 MHz DDR3
    Graphics  AMD Radeon HD 6750M 512 MB
    Software  OS X 10.8.5 (12F45)
    Hardware Overview:
      Model Name:          iMac
      Model Identifier:          iMac12,1
      Processor Name:          Intel Core i5
      Processor Speed:          2.5 GHz
      Number of Processors:          1
      Total Number of Cores:          4
      L2 Cache (per Core):          256 KB
      L3 Cache:          6 MB
      Memory:          20 GB
      Boot ROM Version:          IM121.0047.B1E
      SMC Version (system):          1.71f22
      Serial Number (system):          C0*******HJF
      Hardware UUID:          274F724D-3A05-5775-AAD6-C8C7537328EB
    <Edited By Host>

    Back up all data.
    Select all your mailboxes, and then select
    Mailbox ▹ Export Mailbox...
    from the Mail menu bar. Export the mailboxes to the Desktop folder.
    Make a note of the settings for all your Mail accounts – everything you'd need to reconstruct the settings from scratch.
    Quit Mail. Then select
     ▹ Force Quit...
    from the menu bar. A small window will open with a list of running applications. Mail may appear in that list, even though you quit it. If so, select it and press return. Close the window.
    In the Finder, hold down the option key and select
    Go ▹ Library
    from the menu bar. Move the following items from the folder that opens to the Trash (some may not exist):
    Caches/com.apple.mail
    Saved Application State/com.apple.mail.savedState
    Leave the Finder window open for now.
    Relaunch Mail and test. If the problem is solved, you’re done. Delete the exported mailboxes. Otherwise, quit Mail and move these items, if they exist, from the open Library folder to the Desktop:
    Application Support/AddressBook/MailRecents-v4.abcdmr
    Containers/com.apple.mail
    Mail
    Preferences/com.apple.mail.plist (OS X 10.7 only)
    Preferences/com.apple.mail.searchhistory.plist (OS X 10.7 only)
    Note: you are not moving the Mail application. You’re moving a folder named “Mail.”
    Log out and log back in. Launch Mail. It will behave as if you were setting it up for the first time. Go through the setup process with one of your accounts, using the information you noted earlier. Test. Same problem?
    If there’s no improvement, quit Mail again and put back the items you moved to the Desktop, replacing any newer ones that may have been created in their place. You don’t need to replace the items you moved to the Trash.
    If the issue is resolved, recreate the rest of your Mail settings, then import the mailboxes you exported:
    File ▹ Import Mailbox...
    After importing, test. If Mail is still working, delete the items on the Desktop and close the Finder window.

  • Crystal Reports 2013 freezes after 22 seconds of running report

    I'm running a report that includes 5 linked subreports.  I have parameters for start and end dates for the the data I'm running, and if the report takes longer than 22 seconds to run, the program locks up and I have to manually kill the crw.32 process.  At the bottom of the report I can see where text is constantly overlayed where it says "Subreport: Reading Records" which almost makes me wonder if it's a graphics issue vs. a Crystal issue.  I can see where it began to write "Generating Page 1" over "Subreport: Reading Records".  Any help would be greatly appreciated.  A screenshot of what's happening at the bottom of the program is attached.  I'm running CR Developer 14.1.1.1036.  Thank you very much!

    Hi Drew,
    Remember that each time a subreport is called, it's querying the database again.  If you have 5 linked subreports in a group header or footer that means all 5 of those subreports are hitting the database for each group.
    The screenshot you attached tells me Crystal is busy trying to process the report and is dedicating all of its resources to that.  My guess is if you click on Crystal you the window says it's busy. 
    This could be a resource issue on your database server or your client machine.  So it could be a matter of giving it more time to complete.  It sounds like the problem can be reproduced.  Remove a subreport and see if the report still hangs.  If it does remove another and repeat the process until it doesn't hang.
    If possible, can you filter the data going into the subreports so they process less records?  The less data it has to play with the better the performance.
    Good luck,
    Brian

  • I've noticed this especially when I youtube or video stream for a while. Switching between tabs takes 3-4 seconds. Definitely a memory leak! Is it a general problem or addon specific?

    I've noticed this especially when I youtube or video stream for a while. Switching between tabs takes 3-4 seconds.
    Definitely a memory leak! Is it a general problem or addon specific?
    Also, when I try to close firefox and restart it, the process doesn'y get killed with the normal Command + Q in Mac.
    I need to use Force Quit instead.

    Try updating Flash. You appear to be running an older version dating from September 2010 which might be the cause of the problem. Download from http://get.adobe.com/flashplayer/
    If the problem persists after updating, try running Firefox in [[Safe Mode]]. If it functions properly in that configuration, then one of your add-ons is the culprit.

  • Looping a method every 1/4 second

    I need to write a method that will loop another method
    every 1/4 second. I'm not sure what syntax to use to make
    it work with time. Can someone give me input? Thanks.

    Have u looked at timers. There's
    java.util.Timer;
    and
    javax.swing.Timer;
    http://java.sun.com/docs/books/tutorial/essential/threads/timer.html
    http://java.sun.com/products/jfc/tsc/articles/timer/
    I did something like this to run a method every seconds in a app im making.
    //Swing timer
    Timer timer = new Timer(1000, new TimerListener()); //run every second
    // This runs TimerListener() method every second after i call timer.start()
    class TimerListener implements ActionListener {
    public void actionPerformed(ActionEvent evt) {
    if(whatever ur checking){
    //bla blah
    else{
    timer.stop();
    // clean up ...
    If its not gui the tut suggest to use java.util.Timer;
    http://java.sun.com/docs/books/tutorial/essential/threads/timer.html
    hth

  • Since the last update of firefox, the time has been 25 to 35 seconds to enter bookmarks or even the time it takes to page down when it used to take a few seconds. can you check why it taking so long since the update on firefox.

    since the last update a few days ago of firefox, the time has been 25 to 35 seconds to enter bookmarks or even the time it takes to page down when it used to take a few seconds. can you tell me why it taking so long since the update on firefox. may another update is in order.

    I have now done pretty much every suggestion that even vaguely applies in the various helpful link provided. Thanks for the ongoing help. =)
    I have managed to get FireFox's start-up memory usage down to about 100,000K, however it appears that memory usage keeps creeping up the longer FireFox is open. (It seems to top out around 500,000K.) And I'm not talking open for many hours or days - but rather for minutes and possibly up to a couple hours. (Based on how long I've been fiddling with all this so far.)
    On the plus side, it does not appear GreaseMonkey is the culprit since with it active or disabled this memory creep still occurs. Although having GreaseMonkey enabled definitely increases the rate of memory creep. Though once it has creeped up to 150,000+K, disabling GM does not make it drop back down to the starting 100,000K.
    I should point out I run a MacBook Pro and use Bootcamp to partition the hard drive and run it as a Windows 7 PC about half the time. I am running it literally as a PC or, alternately, as a Mac depending on which hard drive I choose to load. (I'm not "windowing" it.) This problem exists regardless of whether I am using the PC or the Mac. These repairs have been made currently on the PC side, and I will attempt them all again on the Mac side. I find it odd that this enormous memory drain has occurred on 3 different computers at the same time. (The two "halves" of my home laptop as well as the PC at my work place.)

  • Activation of Samsung 226BW Monitor takes about 15 seconds

    Since I have upgraded Mac OS X to Yosemite (10.10) (currently using 10.10.1) my Samsung SyncMaster monitor (226 BW) on Thunderbold takes about 15 seconds for activation. Before I can see a picture on the monitor there is just a rustle with gray and black. I also know a second case where this problem is absolutely the same.
    Has anyone an idea how to solve this? I am using the original Apple Thunderbold to DVI adapter. The problem only occurs if I plugin the thunderbold adapter while my MacBook Pro is already running.

    Reset all settings
    Settings>General>Reset>Reset All Settings

  • Some times when I press the home button to read my finger the screen becomes black and it shows the Apple logo, this take a few seconds to get back the screen and this has been happening even 3 or 4 times in a row!   What should I do?

    Some times when I press the home button to read my finger the screen becomes black and it shows the Apple logo, this take a few seconds to get back the screen and this has been happening even 3 or 4 times in a row!
    What should I do?

    Basic troubleshooting from the User's Guide is reset, restart, restore (first from backup then as new).  Try each of these in order until the issue is resolved.

  • When a process flow activity takes a long time to run.

    Hello,
    I have a process flow activity that sometimes takes a long time to run so that the process flow never ends. Is it possible that I can set the activity so that during a certain time that this has not been executed automatically flow process to continue?
    I'm Using Oracle Warehouse Builder 11g on Windows Server 2003 R1.
    Greetings and thanks.

    What I've done in the past is just use a small polling procedure (PL/SQL) and a conditional transition in the process flow, depending on what the proc returns (Continue or Fail) then the flow of control in the Process is changed.
    I think the key also is to not have too much paralellism going on too, that way it's easy to streamline the PF and remove slow moving processes to a more linear path (stopping bottle necks on your logical AND).
    Edited by: NSNO on Apr 29, 2010 2:31 PM

Maybe you are looking for

  • Trouble printing black and white

    Friends, I'm trying to print black and white on an imac i7, snow leopard, hp premium plus all in one (309g) printer. The prints have a slight purple cast. It is highly noticeable when the prints are placed next to older black and whites printed with

  • Can a signed applet run classes from disk?

    Hi all, I have a signed applet jar and a signed jar file somewhere on disk (I can ensure the jar file is available on client's machine before i run the applet). My applet doesn't let me have file io access from the classes in the jar file on disk. It

  • Remote Control Button Assignment

    I'm having trouble setting the Menu button on my remote. In the inspector I assign the main menu on my dvd to the menu button. However, when you hit the menu button on the remote nothing happens. THen after selecting a track and then hitting the butt

  • Version in BPS

    Hello Gurus. There is a concept of version in BPS. Q1. What is the purpose of having version? Q2. Where do we define version? For ex: i want to plan on version 001,002,003 for different levels. Do i need to upload the version data from flat file or d

  • Slow load + Can't save

    Hi all, I am working on my first Premiere Pro project after switching from FCP (so I am new to the software). The project was going great until this morning when everything started slowing down. First the Auto Save started taking longer. I tried a re