https://robgibbens.com/deploying-a-database-file-with-a-xamarin-forms-app/

https://csharp.hotexamples.com/examples/ZXing.Net.Mobile.Forms/ZXingScannerPage/-/php-zxingscannerpage-class-examples.html




1.

https://stackoverflow.com/questions/989281/how-can-i-programmatically-limit-my-programs-cpu-usage-to-below-70

아래 내용은 Process.Start() 이후

process.PriorityClass = ProcessPriorityClass.BelowNormal;

처리를 해줘야 효과를 볼수 있다.

 

    public static class ProcessHelper

    {

        [Flags]

        public enum ThreadAccess : int

        {

            TERMINATE = (0x0001),

            SUSPEND_RESUME = (0x0002),

            GET_CONTEXT = (0x0008),

            SET_CONTEXT = (0x0010),

            SET_INFORMATION = (0x0020),

            QUERY_INFORMATION = (0x0040),

            SET_THREAD_TOKEN = (0x0080),

            IMPERSONATE = (0x0100),

            DIRECT_IMPERSONATION = (0x0200)

        }

 

        [DllImport("kernel32.dll")]

        static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId);

 

        [DllImport("kernel32.dll")]

        static extern uint SuspendThread(IntPtr hThread);

 

        [DllImport("kernel32.dll")]

        static extern int ResumeThread(IntPtr hThread);

 

        [DllImport("kernel32.dll")]

        static extern int CloseHandle(IntPtr hThread);

 

        public static void ThrottleProcess(int processId, double limit)

        {

            var process = Process.GetProcessById(processId);

            var processName = process.ProcessName;

            var p = new PerformanceCounter("Process", "% Processor Time", processName);

            while (true)

            {

                var interval = 100;

                Thread.Sleep(interval);

 

                var currentUsage = p.NextValue() / Environment.ProcessorCount;

                if (currentUsage < limit) continue;

                var suspensionTime = (currentUsage-limit) / currentUsage * interval;

                SuspendProcess(processId);

                Thread.Sleep((int)suspensionTime);

                ResumeProcess(processId);

            }

        }

 

        private static void SuspendProcess(int pid)

        {

            var process = Process.GetProcessById(pid);

 

            if (process.ProcessName == string.Empty)

                return;

 

            foreach (ProcessThread pT in process.Threads)

            {

                IntPtr pOpenThread = OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)pT.Id);

 

                if (pOpenThread == IntPtr.Zero)

                {

                    continue;

                }

 

                SuspendThread(pOpenThread);

 

                CloseHandle(pOpenThread);

            }

        }

 

        private static void ResumeProcess(int pid)

        {

            var process = Process.GetProcessById(pid);

 

            if (process.ProcessName == string.Empty)

                return;

 

            foreach (ProcessThread pT in process.Threads)

            {

                IntPtr pOpenThread = OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)pT.Id);

 

                if (pOpenThread == IntPtr.Zero)

                {

                    continue;

                }

 

                var suspendCount = 0;

 

                do

                {

                    suspendCount = ResumeThread(pOpenThread);

                } while (suspendCount > 0);

 

                CloseHandle(pOpenThread);

            }

        }

    }

 

2.

https://stackoverflow.com/questions/989281/how-can-i-programmatically-limit-my-programs-cpu-usage-to-below-70

 

아래 내용은 process.PriorityClass = ProcessPriorityClass.BelowNormal 처리를 하지 않아도 효과를 볼수 있다.

이 내용이 확실하게 제어를 해주는것 같다

 

    public class ProcessManager

    {

        [DllImport("kernel32.dll", EntryPoint = "CreateJobObjectW", CharSet = CharSet.Unicode)]

        public static extern IntPtr CreateJobObject(SecurityAttributes JobAttributes, string lpName);

 

        [DllImport("kernel32.dll")]

        [return: MarshalAs(UnmanagedType.Bool)]

        static extern bool AssignProcessToJobObject(IntPtr hJob, IntPtr hProcess);

 

        [DllImport("kernel32.dll")]

        static extern bool SetInformationJobObject(IntPtr hJob, JOBOBJECTINFOCLASS JobObjectInfoClass, IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength);

 

        public class SecurityAttributes

        {

            public int nLength;

            public IntPtr pSecurityDescriptor;

            public bool bInheritHandle;

 

            public SecurityAttributes()

            {

                this.bInheritHandle = true;

                this.nLength = 0;

                this.pSecurityDescriptor = IntPtr.Zero;

            }

        }

 

        public enum JOBOBJECTINFOCLASS

        {

            JobObjectAssociateCompletionPortInformation = 7,

            JobObjectBasicLimitInformation = 2,

            JobObjectBasicUIRestrictions = 4,

            JobObjectEndOfJobTimeInformation = 6,

            JobObjectExtendedLimitInformation = 9,

            JobObjectSecurityLimitInformation = 5,

            JobObjectCpuRateControlInformation = 15

        }

 

        [StructLayout(LayoutKind.Explicit)]

        //[CLSCompliant(false)]

        struct JOBOBJECT_CPU_RATE_CONTROL_INFORMATION

        {

            [FieldOffset(0)]

            public UInt32 ControlFlags;

            [FieldOffset(4)]

            public UInt32 CpuRate;

            [FieldOffset(4)]

            public UInt32 Weight;

        }

 

        public enum CpuFlags

        {

            JOB_OBJECT_CPU_RATE_CONTROL_ENABLE = 0x00000001,

            JOB_OBJECT_CPU_RATE_CONTROL_WEIGHT_BASED = 0x00000002,

            JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP = 0x00000004

        }

 

        public static void ThrottleProcess(Process process)

        {

            //Limit the CPU usage to 45%

            var jobHandle = CreateJobObject(null, null);

            AssignProcessToJobObject(jobHandle, process.Handle);

            var cpuLimits = new JOBOBJECT_CPU_RATE_CONTROL_INFORMATION();

            cpuLimits.ControlFlags = (UInt32)(CpuFlags.JOB_OBJECT_CPU_RATE_CONTROL_ENABLE | CpuFlags.JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP);

            cpuLimits.CpuRate = 45 * 100; // Limit CPu usage to 45%

            var pointerToJobCpuLimits = Marshal.AllocHGlobal(Marshal.SizeOf(cpuLimits));

            Marshal.StructureToPtr(cpuLimits, pointerToJobCpuLimits, false);

            if (!SetInformationJobObject(jobHandle, JOBOBJECTINFOCLASS.JobObjectCpuRateControlInformation, pointerToJobCpuLimits, (uint)Marshal.SizeOf(cpuLimits)))

            {

                Console.WriteLine("Error !");

            }

        }

    }

 

 

사용예시

 

Process process = new Process();

process.EnableRaisingEvents   = false;

process.StartInfo.FileName    = "Test.exe";

//process.StartInfo.Verb        = "Open";

process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

//process.StartInfo.Arguments   = argument;

 

process.Start();

 

// 1번 방법

process.PriorityClass = ProcessPriorityClass.BelowNormal;

ProcessHelper.ThrottleProcess(process.Id, 0.5);

 

// 2번 방법

ProcessManager.ThrottleProcess(process);

 





하담이랑 병원놀이를했다
내가 몸전체가 다아프다고하니
할아버지냐고 물어보길래 그렇다고하니
죽을때가 다되서 그런거란다;;

요즘 패드를 많이 봐서 패드랑 살라고했더니 난 컴퓨터랑 살라고한다;

'Life' 카테고리의 다른 글

하담이 작품  (0) 2019.08.17
iOS 개발자 프로그램 갱신...  (0) 2019.07.30
하담아 ...  (0) 2019.06.18
[Life] 연말정산-원천징수영수증  (0) 2019.05.12
실패  (0) 2019.04.18
구글 광고 수익 증가중..  (0) 2019.04.10

기존에 사용했던 코드가

public static readonly BindableProperty SpacingProperty =

    BindableProperty.Create<WrapLayout, double>(w => w.Spacing, 5,

        propertyChanged: (bindable, oldvalue, newvalue) => ((WrapLayout)bindable).layoutCache.Clear());

 

아래처럼 줄이 그어져 확인해보니


"Create<> (generic) is obsolete as of version 2.1.0 and is no longer supported."

 

위 문구 처럼 Create<> 는 더 이상 지원하지 않는다고한다.

 

위 내용을 지원되는 현재 버전으로 변경하면 아래와 같다.

 

public static readonly BindableProperty SpacingProperty =

    BindableProperty.Create(nameof(Spacing), typeof(double), typeof(WrapLayout), 5.0,

        propertyChanged: (bindable, oldValue, newValue) => ((WrapLayout)bindable).layoutCache.Clear());

 

 

참고

https://forums.xamarin.com/discussion/comment/177726/#Comment_177726

https://forums.xamarin.com/discussion/62984/generic-versions-of-create-are-no-longer-supported-and-deprecated

 

 

BindableProperty.Create<BindablePicker, IList>(p => p.ItemsSource, null,

    propertyChanged: OnItemsSourcePropertyChanged);

=>

BindableProperty.Create(nameof(ItemsSource), typeof(IList), typeof(BindablePicker), null,

    propertyChanged: OnItemsSourcePropertyChanged);

 

 

private static void OnItemsSourcePropertyChanged(BindableObject bindable, IList oldValue, IList newValue)

=>

private static void OnItemsSourcePropertyChanged(BindableObject bindable, object oldValue, object newValue)

 

 

var tgr = new TapGestureRecognizer { NumberOfTapsRequired = 1 };

tgr.Tapped += (sender, args) =>

{

    // 처리할 내용

};

 

this.grid.GestureRecognizers.Add(tgr);

 

 

- NumberOfTapsRequired : tab수로 2로 설정한 경우 두번 tab 한 경우 이벤트가 발생된다.

 

위와 같은 형식으로 Image 도 아래처럼 Click 이벤트를 처리할수 있다.

 

var tgr = new TapGestureRecognizer { NumberOfTapsRequired = 1 };

tgr.Tapped += (sender, args) =>

{

    // 처리할 내용

};

 

this.image.GestureRecognizers.Add(tgr);

 

 

 

xaml 로 처리할때

 

<Label>

    <Label.GestureRecognizers>

        <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>

    </Label.GestureRecognizers>

</Label>

앞으로 앱을 더 늘려야하는데 시간이 될지...

일단 갱신이다. 어휴 왜이렇게 비싸... 얘네들은...;

 

'Life' 카테고리의 다른 글

하담이 작품  (0) 2019.08.17
iOS 개발자 프로그램 갱신...  (0) 2019.07.30
하담아 ...  (0) 2019.06.18
[Life] 연말정산-원천징수영수증  (0) 2019.05.12
실패  (0) 2019.04.18
구글 광고 수익 증가중..  (0) 2019.04.10

unzip 패키지 설치

sudo apt get unzip

 

압축풀기

unzip 파일명.zip

 

--------------------------------------------------------------------------------------------

junijuniya@kjunMainPC:~/digits$ sudo apt-get install unzip

[sudo] password for junijuniya:

Reading package lists... Done

Building dependency tree

Reading state information... Done

Suggested packages:

  zip

The following NEW packages will be installed:

  unzip

0 upgraded, 1 newly installed, 0 to remove and 29 not upgraded.

Need to get 158 kB of archives.

After this operation, 530 kB of additional disk space will be used.

Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 unzip amd64 6.0-20ubuntu1 [158 kB]

Fetched 158 kB in 1s (83.9 kB/s)

Selecting previously unselected package unzip.

(Reading database ... 59636 files and directories currently installed.)

Preparing to unpack .../unzip_6.0-20ubuntu1_amd64.deb ...

Unpacking unzip (6.0-20ubuntu1) ...

Processing triggers for mime-support (3.59ubuntu1) ...

Processing triggers for man-db (2.7.5-1) ...

Setting up unzip (6.0-20ubuntu1) ...

junijuniya@kjunMainPC:~/digits$ unzip v6.1.1.zip

Archive:  v6.1.1.zip

7a3d5f00f3ef0e81cdc3415b03c6ede98c3ef91c

   creating: DIGITS-6.1.1/

   creating: DIGITS-6.1.1/.github/

  inflating: DIGITS-6.1.1/.github/CONTRIBUTING.md

  inflating: DIGITS-6.1.1/.gitignore

  inflating: DIGITS-6.1.1/.gjslintrc

  inflating: DIGITS-6.1.1/.travis.yml

  inflating: DIGITS-6.1.1/CLA

  inflating: DIGITS-6.1.1/LICENSE

  inflating: DIGITS-6.1.1/MANIFEST.in

  inflating: DIGITS-6.1.1/README.md

  inflating: DIGITS-6.1.1/digits-devserver

  inflating: DIGITS-6.1.1/digits-lint

  inflating: DIGITS-6.1.1/digits-test

   creating: DIGITS-6.1.1/digits/

  inflating: DIGITS-6.1.1/digits/.gitignore

  inflating: DIGITS-6.1.1/digits/__init__.py

  inflating: DIGITS-6.1.1/digits/__main__.py

   creating: DIGITS-6.1.1/digits/config/

  inflating: DIGITS-6.1.1/digits/config/__init__.py

  inflating: DIGITS-6.1.1/digits/config/caffe.py

  inflating: DIGITS-6.1.1/digits/config/gpu_list.py

  inflating: DIGITS-6.1.1/digits/config/jobs_dir.py

  inflating: DIGITS-6.1.1/digits/config/log_file.py

  inflating: DIGITS-6.1.1/digits/config/server_name.py

  inflating: DIGITS-6.1.1/digits/config/store_option.py

  inflating: DIGITS-6.1.1/digits/config/tensorflow.py

  inflating: DIGITS-6.1.1/digits/config/torch.py

  inflating: DIGITS-6.1.1/digits/config/url_prefix.py

   creating: DIGITS-6.1.1/digits/dataset/

  inflating: DIGITS-6.1.1/digits/dataset/__init__.py

  inflating: DIGITS-6.1.1/digits/dataset/forms.py

   creating: DIGITS-6.1.1/digits/dataset/generic/

  inflating: DIGITS-6.1.1/digits/dataset/generic/__init__.py

  inflating: DIGITS-6.1.1/digits/dataset/generic/forms.py

  inflating: DIGITS-6.1.1/digits/dataset/generic/job.py

  inflating: DIGITS-6.1.1/digits/dataset/generic/test_views.py

  inflating: DIGITS-6.1.1/digits/dataset/generic/views.py

   creating: DIGITS-6.1.1/digits/dataset/images/

  inflating: DIGITS-6.1.1/digits/dataset/images/__init__.py

   creating: DIGITS-6.1.1/digits/dataset/images/classification/

  inflating: DIGITS-6.1.1/digits/dataset/images/classification/__init__.py

  inflating: DIGITS-6.1.1/digits/dataset/images/classification/forms.py

  inflating: DIGITS-6.1.1/digits/dataset/images/classification/job.py

  inflating: DIGITS-6.1.1/digits/dataset/images/classification/test_imageset_creator.py

  inflating: DIGITS-6.1.1/digits/dataset/images/classification/test_views.py

  inflating: DIGITS-6.1.1/digits/dataset/images/classification/views.py

  inflating: DIGITS-6.1.1/digits/dataset/images/forms.py

   creating: DIGITS-6.1.1/digits/dataset/images/generic/

  inflating: DIGITS-6.1.1/digits/dataset/images/generic/__init__.py

  inflating: DIGITS-6.1.1/digits/dataset/images/generic/forms.py

  inflating: DIGITS-6.1.1/digits/dataset/images/generic/job.py

  inflating: DIGITS-6.1.1/digits/dataset/images/generic/test_lmdb_creator.py

  inflating: DIGITS-6.1.1/digits/dataset/images/generic/test_views.py

  inflating: DIGITS-6.1.1/digits/dataset/images/generic/views.py

  inflating: DIGITS-6.1.1/digits/dataset/images/job.py

  inflating: DIGITS-6.1.1/digits/dataset/images/views.py

  inflating: DIGITS-6.1.1/digits/dataset/job.py

   creating: DIGITS-6.1.1/digits/dataset/tasks/

  inflating: DIGITS-6.1.1/digits/dataset/tasks/__init__.py

  inflating: DIGITS-6.1.1/digits/dataset/tasks/analyze_db.py

  inflating: DIGITS-6.1.1/digits/dataset/tasks/create_db.py

  inflating: DIGITS-6.1.1/digits/dataset/tasks/create_generic_db.py

  inflating: DIGITS-6.1.1/digits/dataset/tasks/parse_folder.py

  inflating: DIGITS-6.1.1/digits/dataset/tasks/parse_s3.py

  inflating: DIGITS-6.1.1/digits/dataset/views.py

  inflating: DIGITS-6.1.1/digits/device_query.py

   creating: DIGITS-6.1.1/digits/download_data/

 extracting: DIGITS-6.1.1/digits/download_data/__init__.py

  inflating: DIGITS-6.1.1/digits/download_data/__main__.py

  inflating: DIGITS-6.1.1/digits/download_data/cifar10.py

......

--------------------------------------------------------------------------------------------

 

+ Recent posts