Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/NSImage/Threaded image load
Function:
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSImage/Threaded image load
This example is the version from Tue, 11th Feb 2013.
Project "Threaded image load.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action() Thread1.run End EventHandler
End Control
Control BevelButton2 Inherits BevelButton
ControlInstance BevelButton2 Inherits BevelButton
EventHandler Sub Action() Thread2.run End EventHandler
End Control
Control Thread1 Inherits Thread
ControlInstance Thread1 Inherits Thread
EventHandler Sub Run() dim t1 as Double = Microseconds dim counter1 as integer = counter dim folder as FolderItem = SpecialFolder.Desktop.Child("test") dim c as integer = folder.Count for i as integer = 1 to c dim file as FolderItem = folder.TrueItem(i) if file<>Nil and file.Visible then dim n as NSImageMBS = NSImageMBS.imageWithContentsOfFile(file) dim Pic as Picture = n.CopyPictureWithMask end if next dim t2 as Double = Microseconds dim counter2 as integer = counter time1 = (t2-t1) / 1000000.0 counterDiff1 = counter2-counter1 End EventHandler
End Control
Control Thread2 Inherits Thread
ControlInstance Thread2 Inherits Thread
EventHandler Sub Run() dim t1 as Double = Microseconds dim counter1 as integer = counter dim folder as FolderItem = SpecialFolder.Desktop.Child("test") dim c as integer = folder.Count for i as integer = 1 to c dim file as FolderItem = folder.TrueItem(i) if file<>Nil and file.Visible then dim n as NSImageMBS = NSImageMBS.imageWithContentsOfFileMT(file) dim Pic as Picture = n.CopyPictureWithMask end if next dim t2 as Double = Microseconds dim counter2 as integer = counter time2 = (t2-t1) / 1000000.0 counterDiff2 = counter2-counter1 End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() if time1<>0 then dim s as string = "Thread1 finished with "+str(time1)+" seconds with "+str(counterDiff1)+" yields" time1 = 0 MsgBox s end if if time2<>0 then dim s as string = "Thread2 finished with "+str(time2)+" seconds with "+str(counterDiff2)+" yields" time2 = 0 MsgBox s end if if time3<>0 then dim s as string = "Thread3 finished with "+str(time3)+" seconds with "+str(counterDiff3)+" yields" time3 = 0 MsgBox s end if End EventHandler
End Control
Control TickTimer Inherits Timer
ControlInstance TickTimer Inherits Timer
EventHandler Sub Action() counter = counter + 1 End EventHandler
End Control
Control ProgressBar1 Inherits ProgressBar
ControlInstance ProgressBar1 Inherits ProgressBar
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control ProgressWheel1 Inherits ProgressWheel
ControlInstance ProgressWheel1 Inherits ProgressWheel
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control BevelButton3 Inherits BevelButton
ControlInstance BevelButton3 Inherits BevelButton
EventHandler Sub Action() Thread3.run End EventHandler
End Control
Control Thread3 Inherits Thread
ControlInstance Thread3 Inherits Thread
EventHandler Sub Run() dim t1 as Double = Microseconds dim counter1 as integer = counter dim folder as FolderItem = SpecialFolder.Desktop.Child("test") dim c as integer = folder.Count for i as integer = 1 to c dim file as FolderItem = folder.TrueItem(i) if file<>Nil and file.Visible then dim p as Picture = Picture.Open(File) end if next dim t2 as Double = Microseconds dim counter2 as integer = counter time3 = (t2-t1) / 1000000.0 counterDiff3 = counter2-counter1 End EventHandler
End Control
Property Time1 As Double
Property Time2 As Double
Property Time3 As Double
Property counter As Integer
Property counterDiff1 As Integer
Property counterDiff2 As Integer
Property counterDiff3 As Integer
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCocoa Plugin.




Links
MBS Xojo Plugins