问题标签 [instances]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
82 浏览

javascript - 通过触发 Parent 方法触发实例方法

通过调用父母的方法在许多孩子中触发方法的最佳方法是什么?

例如,假设我有一个父对象 Foo,它有很多实例:BarX、BarY 等。

有没有什么简单的方法可以在所有情况下触发移动功能?我是否仅限于循环遍历实例并触发这样的函数,还是我可以以某种方式触发 Foo 中的函数并让它向下流动并触发所有扩展 Foo 的实例?

0 投票
1 回答
904 浏览

flash - Flash 自动命名舞台上的对象“instance#”

我的主舞台上已经放置了 2 个 TLF 文本框。在属性检查器窗口中,我给这些实例名称:“txt1”和“txt2”。

我试图有一个 mouseup 事件,并找出它发生在哪个文本框上。

我的文档类有以下代码:

示例输出是:

由于对象已经在舞台上,我不确定如何让 flash 将它们识别为“txt1”和“txt2”而不是“instance#”。我尝试设置 .name 属性,但没有效果。

在发布设置中,我选中了“自动声明阶段实例”。

此外,是否可以为多个滑块组件设置一个更改事件?以下永远不会触发:

感谢您的任何提示

0 投票
3 回答
2810 浏览

azure - Windows azure 应用程序所需的实例数

我是 Windows Azure 的新手,我想托管一个调查应用程序,该应用程序将由 appr 填写。同时有 30.000 名用户。

该应用程序由 1 个 .aspx 页面组成,该页面将发送给客户一次,询问 25 个问题,并在最后给出给定答案的总结。当用户给出答案并点击“下一个问题”按钮时,给定的答案将通过 .ashx 处理程序发送到服务器。响应是下一个问题和答案。在完整回发后,总结会发送给客户端。答案保存在已分区的 Azure 表中,因此每个分区最多可容纳 450 个用户。

我想问一下是否有人可以估计我们需要启动多少个网络角色实例才能让这个应用程序继续运行。(如果这很难说,是不是更有可能启动 5、50 或 500 个实例?)

有什么更好的方法:20 个小型实例或 5 个大型实例?

谢谢你的帮助!

0 投票
1 回答
410 浏览

forms - How to avoid multiple instances of forms in compact framework

I am making a mobile application in compact framework 3.5 for windows mobile 6.5.

The architecture of the application is such that after login the user can see main menu from where he see many options. My application has atleast 40 forms and i have buttons on each of my form for navigation. The problem i am facing is that in the task manager i see multiple forms open and this list continuous to grow as we navigate across the forms

I am looking for a simple solution or any tip from friends out there

0 投票
1 回答
3560 浏览

vb.net - 在 vb 2008 中查找表单的实例

如何找到frmNameHere使用上述代码创建的所有实例?

0 投票
2 回答
735 浏览

python - 为什么我会在不同的模块中获得同一个单例的不同实例?

我有 2 个打印单例实例的文件,但我得到了两个不同的实例。

我正在使用Gary Robinson的 Singleton 代码。

以下是文件:

测试.py

无标题.py

...这是输出python test.py

有人可以向我解释导致这种行为的原因(显然是在模块级别)吗?

0 投票
1 回答
199 浏览

c# - 使用参数启动 ac# 程序的第二个实例,程序的第一个实例使用该参数

我有一个单实例程序,当它运行时,我可以选择将单个参数传递给它。

如果程序在没有参数的情况下运行,只需在选项卡上打开一个 dataGridView 并将客户列表加载到其中。如果我双击一行,它会在第二个选项卡中打开该特定客户,其中包含更多信息。

如果我使用参数(从 00000 到 99999 的客户 ID 号)启动程序,它会自动切换到第二个选项卡并加载各个客户数据。

到目前为止一切都很好,但是,我想做的是让我的程序运行,但是如果使用参数调用程序的第二个实例,例如 Program.exe 1234,我希望它直接跳转到第二个选项卡并显示该客户的详细信息。

这就是我到目前为止所拥有的。我正在尝试这样做的方式是在吠叫错误的树吗?我得到的印象是 Program.exe 应该正在监听另一个正在运行的实例并使用传递给它的参数。

任何建议将不胜感激。

// check that the parameter passed is actually a valid number, otherwise just act like no params passed. try { testSiteid = Convert.ToInt32(siteid); if ((testSiteid > 00000) || (testSiteid < 99999)) { gotosite = true; } else { siteid = ""; } } catch (Exception e) { // If you get an exception it means siteid had duff data passed into it. }

/// Check if it's running, if it is, pass siteid and gotosite through... and acts as if it has a valid siteid passed to it. // Application.Run(new Form1(siteid, gotosite)); Run(siteid, gotosite, secondInstance); } private static IntPtr GetCurrentInstanceWindowHandle() { IntPtr hWnd = IntPtr.Zero; Process process = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName(process.ProcessName); foreach(Process _process in processes) { // Get the first instance that is not this instance, has the // same process name and was started from the same file name // and location. Also check that the process has a valid // window handle in this session to filter out other user's // processes. if (_process.Id != process.Id && _process.MainModule.FileName == process.MainModule.FileName && _process.MainWindowHandle != IntPtr.Zero) { hWnd = _process.MainWindowHandle; break; } } return hWnd; } /// SwitchToCurrentInstance private static void SwitchToCurrentInstance(string siteid, bool gotosite, bool secondInstance) { IntPtr hWnd = GetCurrentInstanceWindowHandle(); if (hWnd != IntPtr.Zero) { // Restore window if minimised. Do not restore if already in // normal or maximised window state, since we don't want to // change the current state of the window. if (IsIconic(hWnd) != 0) { ShowWindow(hWnd, SW_RESTORE); } // Set foreground window. SetForegroundWindow(hWnd); secondInstance = true; } } /// Execute a form base application if another instance already running on /// the system activate previous one /// <param name="frmMain">main form</param> /// true if no previous instance is running // public static bool Run(System.Windows.Forms.Form frmMain) public static bool Run(string siteid, bool gotosite, bool secondInstance) { if(IsAlreadyRunning()) { //set focus on previously running app SwitchToCurrentInstance(siteid, gotosite, secondInstance); return false; } Application.Run(new Form1(siteid, gotosite, secondInstance)); return true; } /// check if given exe alread running or not /// returns true if already running private static bool IsAlreadyRunning() { string strLoc = Assembly.GetExecutingAssembly().Location; FileSystemInfo fileInfo = new FileInfo(strLoc); string sExeName = fileInfo.Name; bool bCreatedNew; mutex = new Mutex(true, "Global\\"+sExeName, out bCreatedNew); if (bCreatedNew) mutex.ReleaseMutex(); return !bCreatedNew; } static Mutex mutex; const int SW_RESTORE = 9; }

}

0 投票
1 回答
3177 浏览

magento - 在多个 magento 实例上设置 Cron 作业

是否有人对跨应用程序的多个实例的 Magento 模块级 cron 作业有任何经验?

我知道 Magento 将 cron 记录添加到 cron_schedule 表中 - Magento 应用程序的每个实例都会将它自己的调用添加到模块级 cron 吗?

所有应用程序实例都在查看同一个数据库。

感谢您的任何见解。

0 投票
3 回答
789 浏览

flash - 是否有关于闪存如何跨关键帧管理命名实例的文档?

我正在寻找有关 Flash 如何跨关键帧管理具有相同名称的对象实例的技术文档。

到目前为止,我注意到当播放头移动到另一个帧时,如果同名对象具有相同的类型,则实例及其动态设置的属性会被保留。

另一方面,一旦播放头转到命名实例是不同类型的帧,它就会创建一个新类型的新实例(使用原始名称),而旧类型的原始实例是永久丢弃并且命名实例上的所有动态设置属性都将丢失(因为它是一个新实例)。

如果你回到原来的框架,它不会恢复原来的实例,而是把它当作另一个变化,并再次构造一个新的实例。是否有任何文档描述了这种行为?

关于“时间线实例的连续性”的类似问题:http ://www.kirupa.com/forum/showthread.php?t=316612 我也很惊讶属性会延续。这似乎是一个运行时功能,其中 Flash 将创建一个新实例,仅当(实例名称/符号类型)对在下一个关键帧中发生变化(即,如果命名实例“obj”在两者中都指“球”)关键帧,那么它将保持相同的实例;但如果“obj”在下一个关键帧中引用“正方形”,则将创建一个新的“正方形”实例)。这是有道理的,但是这种行为是否得到保证?

0 投票
6 回答
67 浏览

javascript - 关于 Javascript 属性和实例的问题

我无法弄清楚自己为什么foo.bar在示例中是undefined,你能解释一下吗?

Q2:如何向String实例添加对属性和方法的引用foo

感谢您的帮助,谢谢。

- 编辑 -

注意:问题是关于通用 String实例,而不是String 全局对象。因此,不能像有人建议的那样使用“经典”原型,因为这样每个 String 实例都会有一个名为 的属性bar,而我只想增加某些实例