Class: VirtualBox::COM::Model::Progress

Inherits:
NSISupports show all
Defined in:
lib/virtualbox/com/model/4.2.rb,
lib/virtualbox/com/model/4.1-generated.rb,
lib/virtualbox/com/model/4.2-generated.rb

Instance Attribute Summary

Attributes inherited from AbstractInterface

#implementer

Instance Method Summary collapse

Methods inherited from AbstractInterface

#cast, function, functions, #initialize, #inspect, member, members, properties, property

Methods inherited from AbstractModel

iid

Constructor Details

This class inherits a constructor from VirtualBox::COM::AbstractInterface

Instance Method Details

#wait(interval_percent = 1) ⇒ Object

This method blocks the execution while the operations represented by this VirtualBox::COM::Model::Progress object execute, but yields a block every ‘x` percent (interval given in parameters).



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/virtualbox/com/model/4.2.rb', line 37

def wait(interval_percent=1)
    # If no block is given we just wait until completion, not worrying
    # about tracking percentages.
    if !block_given?
        wait_for_completion(-1)
        return
    end

    # Initial value forces the 0% yield
    last_reported = -100

    while true
        delta = percent - last_reported
        last_reported += delta
        yield self if delta >= interval_percent
        
        # This either sleeps for half a second or returns on completion
        wait_for_completion(500)
        
        break if completed || canceled
        
        # Pass off execution so other threads can run
        Thread.pass
    end
end