Instance Method インスタンスメソッド

cancel()

Advises the operation object that it should stop executing its task. それがそれのタスクの遂行を停止すべきオペレーションオブジェクトを勧告します。

Declaration 宣言

func cancel()

Discussion 議論

This method does not force your operation code to stop. Instead, it updates the object’s internal flags to reflect the change in state. If the operation has already finished executing, this method has no effect. Canceling an operation that is currently in an operation queue, but not yet executing, makes it possible to remove the operation from the queue sooner than usual. このメソッドは、あなたのオペレーションコードに停止を強制しません。その代わりに、それはオブジェクトのもつ内部フラグを状態の変化を反映するように更新します。オペレーションがすでに遂行を終了しているならば、このメソッドは効果を持ちません。現在オペレーションキューの中にある、しかしまだ遂行中になっていないオペレーションを取り消すことは、そのオペレーションをいつもよりすみやかにキューから取り除けるようにします。

In macOS 10.6 and later, if an operation is in a queue but waiting on unfinished dependent operations, those operations are subsequently ignored. Because it is already cancelled, this behavior allows the operation queue to call the operation’s start() method sooner and clear the object out of the queue. If you cancel an operation that is not in a queue, this method immediately marks the object as finished. In each case, marking the object as ready or finished results in the generation of the appropriate KVO notifications. macOS 10.6以降では、あるオペレーションがキューの中にあるしかし終わっていない依存オペレーションそれらを待っているならば、それらオペレーションはその後は無視されます。それがすでに取り消されることから、この挙動はオペレーションキューにそのオペレーションのもつstart()メソッドをよりすみやかに呼び出してキューの外へオブジェクトを片付けることを許可します。あなたがキューの中にないオペレーションをキャンセルするならば、このメソッドは直ぐにそのオブジェクトを終了したと印します。それぞれの場合において、オブジェクトを準備できたまたは終了したと印することは、適切なKVO通知の生成という結果になります。

In versions of macOS prior to 10.6, an operation object remains in the queue until all of its dependencies are removed through the normal processes. Thus, the operation must wait until all of its dependent operations finish executing or are themselves cancelled and have their start() method called. 10.6に先立つmacOSのバージョンでは、オペレーションオブジェクトはキューの中に残ったままです、それの依存関係の全てが通常の処理を通して取り除かれるまでは。したがって、オペレーションは、それの依存オペレーションそれらの全てが遂行を終了するまたはそれら自身キャンセルされてそれらのstart()メソッドが呼び出されるまで待機しなければなりません。

For more information on what you must do in your operation objects to support cancellation, see Responding to the Cancel Command. あなたがあなたのオペレーションオブジェクトにおいて取り消しをサポートするためにしなければならない事に関するさらなる情報として、取り消しコマンドに応答するを見てください。

See Also 参照

Related Documentation 関連文書