`
qqjavagood
  • 浏览: 95362 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论
阅读更多

    Every time resources in the workspace change, a resource change notification is broadcast, and autobuild gets a chance to run. This can become very costly if you are making several changes in succession to the workspace. To avoid these extra builds and notifications, it is very important that you batch all of your workspace changes into a single workspace operation. It is easy to accidentally cause extra builds if you aren’t very careful about batching your changes. For example, even creating and modifying attributes on IMarker objects will cause separate resource change events if they are not batched.

Two different mechanisms are available for batching changes. To run a series of changes in the current thread, use IWorkspaceRunnable. Here is an example of a workspace runnable that creates two folders:

   final IFolder folder1 = ..., folder2 = ...;
   workspace.run(new IWorkspaceRunnable() {
      public void run(IProgressMonitor monitor) {
         folder1.create(IResource.NONE, true, null);
         folder2.create(IResource.NONE, true, null);
      }
   }, null);

The other mechanism for batching resource changes is a WorkspaceJob. Introduced in Eclipse 3.0, this mechanism is the asynchronous equivalent of IWorkspaceRunnable. When you create and schedule a workspace job, it will perform the changes in a background thread and then cause a single resource change notification and autobuild to occur. Here is sample code using a workspace job:
   final IFolder folder1 = ..., folder2 = ...;
   Job job = new WorkspaceJob("Creating folders") {
      public IStatus runInWorkspace(IProgressMonitor monitor) 
         throws CoreException {
         folder1.create(IResource.NONE, true, null);
         folder2.create(IResource.NONE, true, null);
         return Status.OK_STATUS;
      }
   };
   job.schedule();


原文:http://wiki.eclipse.org/FAQ_How_do_I_prevent_builds_between_multiple_changes_to_the_workspace%3F

 
0
0
分享到:
评论

相关推荐

    UNIX编程常见问题解答

    1.7 How do I get my program to act like a daemon? 1.8 How can I look at process in the system like ps does? 1.9 Given a pid, how can I tell if it's a running program? 1.10 What's the return value ...

    Unix编程常见问题解答 高清PDF含书签目录

    1.6.2 How do I prevent them from occuring? 我怎样避免它们的出现? 1.7 How do I get my program to act like a daemon? 我怎样使我的程序作为守护程序运行? 1.8 How can I look at process in the system like ...

    Common System and Software Testing Pitfalls How to Prevent and Mitigate epub

    Common System and Software Testing Pitfalls How to Prevent and Mitigate Them 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    a project model for the FreeBSD Project.7z

    I would like to thank the following people for taking the time to explain things that were unclear to me and for proofreading the document. Andrey A. Chernov Bruce A. Mah Dag-Erling Smørgrav ...

    Sakemail

    Some changes to the code.17/11/971.2.1- Now, all searches are made in case-insensitive, it could prevent some unexpected responses (no one reported, but...). Some changes to the code (again).20/11/...

    WordPress 2.7 Cookbook.pdf

    How to do it 216 How it works 217 There's more... 217 Managing who Sees Ads 218 Getting ready 218 How to do it 219 How it works 220 There's more... 220 Advanced conditions 221 Inserting ads ...

    How to write great essays

    spelling ,usage,and how to prevent and correct these errors,Every chapter is designed to relate directly to your essay,giving you the knowledge and the know -how you need to secceed. The book is ...

    apktool documentation

    original = META-INF folder / AndroidManifest.xml, which are needed to retain the signature of apks to prevent needing to resign. Used with -c / --copy-original on [b]uild unknown = Files / folders ...

    Foundations of Agile Python Development (2008).pdf

    I show you how to use it from the command line and from Eclipse using the Subversive plug-in. Chapter 4:Setuptools:Harnessing Your Code You can’t replicate your work for testing purposes without ...

    Eclipse Rich Ajax Platform: Bringing Rich Client to the Web

    Eclipse Rich Ajax Platform: Bringing Rich Client to the Web Paperback: 148 pages Publisher: Apress; 1 edition (December 29, 2008) Language: English ISBN-10: 1430218835 ISBN-13: 978-1430218838 ...

    BURNINTEST--硬件检测工具

    - Added a hot Key, F4, to set the auto run flag and run the tests (i.e. set "-r" and then run the tests). - Other minor changes. Release 5.3 build 1018 WIN32 release 16 April 2008 - Added an ...

    Credit Risk Modeling Using Bayesian Networks

    As a result, banks do not man- age to make a quantitative link to the correlation driving risks and fail to prevent concentrations from accumulating. In this paper, we argue that Bayesian networks ...

    Android代码-Prevent-Screen-Off

    Prevent-Screen-Off Featured in: Medium What is this library for? Ideally, when you user is looking at the screen, your application should not turn the screen off. This is huge deal for the ...

    VB编程资源大全(英文源码 其它)

    <END><br>77,MousePointer.zip 1 simple line of code to show the effects of how the Mouse Pointer changes with the click of a button. <END><br>78,ShutDnCtl.zip This has been tested on Windows 9x,...

    微软内部资料-SQL性能优化3

    In this scenario, since T1 believes it locks the entire table, it might inadvertently make changes to the same row that T2 thought it has locked exclusively. In a multigranular locking environment, ...

    Dropout:A Simple Way to Prevent Neural Networks from Overfitting.zip

    Dropout:A Simple Way to Prevent Neural Networks from Overfitting.zip

    微软内部资料-SQL性能优化2

    Before we look at how SQL Server uses and manages its memory, we need to ensure a full understanding of the more common memory related terms. The following definitions will help you understand how SQL...

    外文翻译 stus MVC

    The Web brought some unique challenges to software developers, most notably the stateless connection between the client and the server. This stateless behavior made it difficult for the model to ...

    Common System and Software Testing Pitfalls How to Prevent and Mitigate 无水印原版pdf

    Common System and Software Testing Pitfalls How to Prevent and Mitigate Them 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如...

    麦肯锡2010.01最新报告debt and deleveraging:The global credit bubble and its economic consequences

    Today, government and business leaders are facing the twin questions of how to prevent similar crises in the future and how to guide their economies through the looming and lengthy process of debt ...

Global site tag (gtag.js) - Google Analytics